marcoCasamento / Hangfire.Redis.StackExchange

HangFire Redis storage based on original (and now unsupported) Hangfire.Redis but using lovely StackExchange.Redis client
Other
456 stars 109 forks source link

Extensions needed for dashboard metrics #39

Open dotnetshadow opened 7 years ago

dotnetshadow commented 7 years ago

Hi there,

I noticed with the latest release 1.6.7.7, you have an extension method to use .UseRedisStore() which is nice.

The problem I'm facing now is that if I use this extension method then I'm not sure how I can read dashboardmetrics without passing in a storage and redefining the storage:

services.AddHangfire(configuration =>
{
                configuration.UseRedisStorage("127.0.0.1:6379,allowAdmin=true,abortConnect=false", new RedisStorageOptions { Db = 1, Prefix = "hangfire:app1:", SucceededListSize = 10, DeletedListSize = 10 });
                configuration.UseColouredConsoleLogProvider();
});

// NEED TO GET STORAGE HERE----------------------------V
GlobalConfiguration.Configuration.UseDashboardMetric(storage.GetDashboardMetricFromRedisInfo("Redis Version", RedisInfoKeys.redis_version));

I've actually seen another library implement this by allowing the RedisStrorage to have an extension method. You can see details of this here https://github.com/BoltR/Hangfire.Redis.StackExchange

marcoCasamento commented 7 years ago

Yep, that has been added by @codeyu, a fluent syntax for configuration really helps on readability. Seems like a nice addition, would you mind a PR ?

pieceofsummer commented 7 years ago

I think GetDashboardMetricFromRedisInfo() should not be an instance method of RedisStorage at all. It can safely be made static, or even turn into an extension method on IGlobalConfiguration.