public HystrixDashboardStream.DashboardData GetTestData() { var commandKey = new HystrixCommandKeyDefault("command"); var tpKey = new HystrixThreadPoolKeyDefault("threadPool"); var collapserKey = new HystrixCollapserKeyDefault("collapser"); var commandMetric = new HystrixCommandMetrics( commandKey, new HystrixCommandGroupKeyDefault("group"), tpKey, new HystrixCommandOptions(), HystrixEventNotifierDefault.GetInstance()); var threadPoolMetric = HystrixThreadPoolMetrics.GetInstance( tpKey, new HystrixSyncTaskScheduler(new HystrixThreadPoolOptions()), new HystrixThreadPoolOptions()); var commandMetrics = new List <HystrixCommandMetrics>() { commandMetric }; var collapserOptions = new HystrixCollapserOptions(collapserKey); var threadPoolMetrics = new List <HystrixThreadPoolMetrics>() { threadPoolMetric }; var collapserMetrics = new List <HystrixCollapserMetrics>() { HystrixCollapserMetrics.GetInstance(collapserKey, collapserOptions) }; return(new HystrixDashboardStream.DashboardData(commandMetrics, threadPoolMetrics, collapserMetrics)); }
private static HystrixCollapserOptions Options(IHystrixCollapserKey key, int timerDelay) { var opts = new HystrixCollapserOptions(key) { TimerDelayInMilliseconds = timerDelay }; return opts; }
public User GetById(int id) { var collapserOptions = new HystrixCollapserOptions(HystrixCollapserKeyDefault.AsKey("UserCollapser"), RequestCollapserScope.GLOBAL) { TimerDelayInMilliseconds = 5000, MaxRequestsInBatch = 10, RequestCacheEnabled = true }; var collapser = new UserServiceCollapser(collapserOptions, _loggerFactory.CreateLogger <UserServiceCollapser>()); collapser.UserId = id; return(collapser.Execute()); }