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 WriteCollapserConfigJson(JsonTextWriter json, IHystrixCollapserKey collapserKey, HystrixCollapserConfiguration collapserConfig) { json.WriteObjectFieldStart(collapserKey.Name); json.WriteIntegerField("maxRequestsInBatch", collapserConfig.MaxRequestsInBatch); json.WriteIntegerField("timerDelayInMilliseconds", collapserConfig.TimerDelayInMilliseconds); json.WriteBooleanField("requestCacheEnabled", collapserConfig.IsRequestCacheEnabled); json.WriteObjectFieldStart("metrics"); HystrixCollapserConfiguration.CollapserMetricsConfig metricsConfig = collapserConfig.CollapserMetricsConfiguration; json.WriteIntegerField("percentileBucketSizeInMilliseconds", metricsConfig.RollingPercentileBucketSizeInMilliseconds); json.WriteIntegerField("percentileBucketCount", metricsConfig.RollingCounterNumberOfBuckets); json.WriteBooleanField("percentileEnabled", metricsConfig.IsRollingPercentileEnabled); json.WriteIntegerField("counterBucketSizeInMilliseconds", metricsConfig.RollingCounterBucketSizeInMilliseconds); json.WriteIntegerField("counterBucketCount", metricsConfig.RollingCounterNumberOfBuckets); json.WriteEndObject(); json.WriteEndObject(); }