Example #1
0
        public async Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                bool   isset_defaultConfig  = false;
                bool   isset_serviceConfigs = false;
                TField field;
                await iprot.ReadStructBeginAsync(cancellationToken);

                while (true)
                {
                    field = await iprot.ReadFieldBeginAsync(cancellationToken);

                    if (field.Type == TType.Stop)
                    {
                        break;
                    }

                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.Struct)
                        {
                            DefaultConfig = new ThrottlingConfig();
                            await DefaultConfig.ReadAsync(iprot, cancellationToken);

                            isset_defaultConfig = true;
                        }
                        else
                        {
                            await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.List)
                        {
                            {
                                TList _list0 = await iprot.ReadListBeginAsync(cancellationToken);

                                ServiceConfigs = new List <ServiceThrottlingConfig>(_list0.Count);
                                for (int _i1 = 0; _i1 < _list0.Count; ++_i1)
                                {
                                    ServiceThrottlingConfig _elem2;
                                    _elem2 = new ServiceThrottlingConfig();
                                    await _elem2.ReadAsync(iprot, cancellationToken);

                                    ServiceConfigs.Add(_elem2);
                                }
                                await iprot.ReadListEndAsync(cancellationToken);
                            }
                            isset_serviceConfigs = true;
                        }
                        else
                        {
                            await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                        }
                        break;

                    default:
                        await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);

                        break;
                    }

                    await iprot.ReadFieldEndAsync(cancellationToken);
                }

                await iprot.ReadStructEndAsync(cancellationToken);

                if (!isset_defaultConfig)
                {
                    throw new TProtocolException(TProtocolException.INVALID_DATA);
                }
                if (!isset_serviceConfigs)
                {
                    throw new TProtocolException(TProtocolException.INVALID_DATA);
                }
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }
        public async Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
        {
            iprot.IncrementRecursionDepth();
            try
            {
                bool   isset_serviceName = false;
                bool   isset_config      = false;
                TField field;
                await iprot.ReadStructBeginAsync(cancellationToken);

                while (true)
                {
                    field = await iprot.ReadFieldBeginAsync(cancellationToken);

                    if (field.Type == TType.Stop)
                    {
                        break;
                    }

                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.String)
                        {
                            ServiceName = await iprot.ReadStringAsync(cancellationToken);

                            isset_serviceName = true;
                        }
                        else
                        {
                            await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.Struct)
                        {
                            Config = new ThrottlingConfig();
                            await Config.ReadAsync(iprot, cancellationToken);

                            isset_config = true;
                        }
                        else
                        {
                            await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
                        }
                        break;

                    default:
                        await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);

                        break;
                    }

                    await iprot.ReadFieldEndAsync(cancellationToken);
                }

                await iprot.ReadStructEndAsync(cancellationToken);

                if (!isset_serviceName)
                {
                    throw new TProtocolException(TProtocolException.INVALID_DATA);
                }
                if (!isset_config)
                {
                    throw new TProtocolException(TProtocolException.INVALID_DATA);
                }
            }
            finally
            {
                iprot.DecrementRecursionDepth();
            }
        }
Example #3
0
 public ThrottlingResponse(ThrottlingConfig defaultConfig, List <ServiceThrottlingConfig> serviceConfigs) : this()
 {
     this.DefaultConfig  = defaultConfig;
     this.ServiceConfigs = serviceConfigs;
 }
 public ServiceThrottlingConfig(string serviceName, ThrottlingConfig config) : this()
 {
     this.ServiceName = serviceName;
     this.Config      = config;
 }