marcoCasamento / Hangfire.Redis.StackExchange

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

Why does not has explored API that let user update redis prefix option in runtime when create job. #124

Closed ltb27 closed 10 months ago

ltb27 commented 10 months ago

When create job, in JobFilter OnCreating metthod.The CreatingContext explore the Storage that is assign to client when create the job.Now i just get that job and can not change it, but i want some way to change the Storage Prefix when creating the job to create job base on some dynamic data.

marcoCasamento commented 10 months ago

Not sure of the classes you're talking about, but both IJobFilter and the Creating Context (as well as all of the "Contexts") are parts of Hangfire, not of Hangfire.Redis.StackExchange, so, if you need some API in those classes you should discuss it in main Hangfire project. Also, It's not clear what problem you're trying to solve.

ltb27 commented 10 months ago

I use hangfire for a app with mutil tenacy so that, my app has each site(tenecy) own each hangfire server and dashboard . I know that hangfire server,hangfire dashboard, hangfire client have to use the same JobStorage(RedisStorege) .I Created each site own each storage, different from each other with prefix.So i don want each time have to pass HttpContext.Host.Host to get site name then get the valid Client(with valid storage prefix) . I want to use JobStorage.Current(defaut useage of hangfire) but in job filter, onCreating , when access Storage prop in CreatingContext , i want to be able to change prefix of that redisStorage.

marcoCasamento commented 10 months ago

ok, so you want to separate jobs enqueuing for each tenant. The Tenant is usually a "context" information, and you can probably leverage dependency injection to return the client you need. That will leave out the static facade of "JobServer.Current", which, frankly, is not adequated to any usage slightly more complex than "basic".

As per the API modification, I don't think you'll ever get a merged PR on hangfire for this purpose as it's easily (and more elegantly I'd say) achieved in other ways, but if the Hangfire interfaces/classes get updated to include such API, I can take care of updating the related implementation.

Going to close the request as there is nothing to implement by the moment