public HystrixStreamHandler()
        {
            int pollingInterval;

            if (!int.TryParse(ConfigurationManager.AppSettings[PollingIntervalInMilliseconds], out pollingInterval))
            {
                pollingInterval = 500;
            }

            Log.InfoFormat("Creating HystrixStreamHandler with interval {0}", pollingInterval);

            endpoint = new HystrixMetricsStreamEndpoint(new HystrixCommandFactory(), pollingInterval);
        }
Exemple #2
0
        public HystrixStreamHandler()
        {
            var configSection = ConfigurationManager.GetSection("hystrix.dotnet/hystrix") as HystrixConfigSection;

            int pollingInterval = configSection?.MetricsStreamPollIntervalInMilliseconds ?? 500;

            log.InfoFormat("Creating HystrixStreamHandler with interval {0}", pollingInterval);

            var helper = new AspNetHystrixCommandFactoryHelper();

            endpoint = new HystrixMetricsStreamEndpoint(
                helper.CreateFactory(),
                pollingInterval);
        }
Exemple #3
0
        public async Task Invoke(HttpContext context, IHystrixMetricsStreamEndpoint streamEndpoint)
        {
            log.Info("Starting HystrixStreamHandler request");

            var response = context.Response;

            // Do not cache
            response.Headers.Add("Cache-Control", "no-cache");
            response.Headers.Add("Expires", "-1");
            response.Headers.Add("Pragma", "no-cache");

            response.ContentType = "text/event-stream";

            await streamEndpoint.PushContentToOutputStream(response.Body, () => { }, context.RequestAborted).ConfigureAwait(false);

            log.Info("Ending HystrixStreamMiddleware request");
        }