Beispiel #1
0
        static GatewayBucket()
        {
            var buckets = new[]
            {
                // Limit is 120/60s, but 3 will be reserved for heartbeats (2 for possible heartbeats in the same timeframe and a possible failure)
                new GatewayBucket(GatewayBucketType.Unbucketed, BucketId.Create(null, "<gateway-unbucketed>", null), 117, 60),
                new GatewayBucket(GatewayBucketType.Identify, BucketId.Create(null, "<gateway-identify>", null), 1, 5),
                new GatewayBucket(GatewayBucketType.PresenceUpdate, BucketId.Create(null, "<gateway-presenceupdate>", null), 5, 60),
            };

            var builder = ImmutableDictionary.CreateBuilder <GatewayBucketType, GatewayBucket>();

            foreach (var bucket in buckets)
            {
                builder.Add(bucket.Type, bucket);
            }
            DefsByType = builder.ToImmutable();

            var builder2 = ImmutableDictionary.CreateBuilder <BucketId, GatewayBucket>();

            foreach (var bucket in buckets)
            {
                builder2.Add(bucket.Id, bucket);
            }
            DefsById = builder2.ToImmutable();
        }
Beispiel #2
0
 internal (RequestBucket, BucketId) UpdateBucketHash(BucketId id, string discordHash)
 {
     if (!id.IsHashBucket)
     {
         var bucket       = BucketId.Create(discordHash, id);
         var hashReqQueue = (RequestBucket)_buckets.GetOrAdd(bucket, _buckets[id]);
         _buckets.AddOrUpdate(id, bucket, (oldBucket, oldObj) => bucket);
         return(hashReqQueue, bucket);
     }
     return(null, null);
 }
Beispiel #3
0
        static ClientBucket()
        {
            ClientBucket[] buckets = new[]
            {
                new ClientBucket(ClientBucketType.Unbucketed, BucketId.Create(null, "<unbucketed>", null), 10, 10),
                new ClientBucket(ClientBucketType.SendEdit, BucketId.Create(null, "<send_edit>", null), 10, 10)
            };

            ImmutableDictionary <ClientBucketType, ClientBucket> .Builder builder = ImmutableDictionary.CreateBuilder <ClientBucketType, ClientBucket>();
            foreach (ClientBucket bucket in buckets)
            {
                builder.Add(bucket.Type, bucket);
            }
            DefsByType = builder.ToImmutable();

            ImmutableDictionary <BucketId, ClientBucket> .Builder builder2 = ImmutableDictionary.CreateBuilder <BucketId, ClientBucket>();
            foreach (ClientBucket bucket in buckets)
            {
                builder2.Add(bucket.Id, bucket);
            }
            DefsById = builder2.ToImmutable();
        }
Beispiel #4
0
        static GatewayBucket()
        {
            GatewayBucket[] buckets = new[]
            {
                new GatewayBucket(GatewayBucketType.Unbucketed, BucketId.Create(null, "<gateway-unbucketed>", null), 120, 60),
                new GatewayBucket(GatewayBucketType.Identify, BucketId.Create(null, "<gateway-identify>", null), 1, 5),
                new GatewayBucket(GatewayBucketType.PresenceUpdate, BucketId.Create(null, "<gateway-presenceupdate>", null), 5, 60),
            };

            ImmutableDictionary <GatewayBucketType, GatewayBucket> .Builder builder = ImmutableDictionary.CreateBuilder <GatewayBucketType, GatewayBucket>();
            foreach (GatewayBucket bucket in buckets)
            {
                builder.Add(bucket.Type, bucket);
            }
            DefsByType = builder.ToImmutable();

            ImmutableDictionary <BucketId, GatewayBucket> .Builder builder2 = ImmutableDictionary.CreateBuilder <BucketId, GatewayBucket>();
            foreach (GatewayBucket bucket in buckets)
            {
                builder2.Add(bucket.Id, bucket);
            }
            DefsById = builder2.ToImmutable();
        }