private static void SerializeConfiguration(JsonTextWriter writer, HystrixConfiguration config) { writer.WriteStartObject(); writer.WriteStringField("type", "HystrixConfig"); writer.WriteObjectFieldStart("commands"); foreach (var entry in config.CommandConfig) { IHystrixCommandKey key = entry.Key; HystrixCommandConfiguration commandConfig = entry.Value; WriteCommandConfigJson(writer, key, commandConfig); } writer.WriteEndObject(); writer.WriteObjectFieldStart("threadpools"); foreach (var entry in config.ThreadPoolConfig) { IHystrixThreadPoolKey threadPoolKey = entry.Key; HystrixThreadPoolConfiguration threadPoolConfig = entry.Value; WriteThreadPoolConfigJson(writer, threadPoolKey, threadPoolConfig); } writer.WriteEndObject(); writer.WriteObjectFieldStart("collapsers"); foreach (var entry in config.CollapserConfig) { IHystrixCollapserKey collapserKey = entry.Key; HystrixCollapserConfiguration collapserConfig = entry.Value; WriteCollapserConfigJson(writer, collapserKey, collapserConfig); } writer.WriteEndObject(); writer.WriteEndObject(); }
private static void WriteThreadPoolConfigJson(JsonTextWriter json, IHystrixThreadPoolKey threadPoolKey, HystrixThreadPoolConfiguration threadPoolConfig) { json.WriteObjectFieldStart(threadPoolKey.Name); json.WriteIntegerField("coreSize", threadPoolConfig.CoreSize); json.WriteIntegerField("maximumSize", threadPoolConfig.MaximumSize); json.WriteIntegerField("maxQueueSize", threadPoolConfig.MaxQueueSize); json.WriteIntegerField("queueRejectionThreshold", threadPoolConfig.QueueRejectionThreshold); json.WriteIntegerField("keepAliveTimeInMinutes", threadPoolConfig.KeepAliveTimeInMinutes); json.WriteBooleanField("allowMaximumSizeToDivergeFromCoreSize", threadPoolConfig.AllowMaximumSizeToDivergeFromCoreSize); json.WriteIntegerField("counterBucketSizeInMilliseconds", threadPoolConfig.RollingCounterBucketSizeInMilliseconds); json.WriteIntegerField("counterBucketCount", threadPoolConfig.RollingCounterNumberOfBuckets); json.WriteEndObject(); }