We are leaving Russia. We are against aggression and war with Ukraine. It is a tragedy for our nations, it is a nightmare

Using Throttling

So I must be missing something because all of your documentation is pretty awesome. However, I am confused about how to use throttling. I want to limit a specific method so that only a limited number are ever queued within a window. However…

The examples that show throttling include an example like the one below, but do not answer where this code should be put. Should it be tied to where I configure hangfire? How does hangfire know this manager exists? What manages the lifetime of the Throttling Manager.

Is there a more code-complete example instead of just snippets of code.

IThrottlingManager manager = new ThrottlingManager();
manager.AddOrUpdateFixedWindow(“github”, new FixedWindowOptions(5000, TimeSpan.FromHours(1)));

I’m sorry to bump this, but I’m running into a similar issue.
I’d like to know this too if anyone knows.

I’m getting an error, and it’s because I’m not familiar with where to use the ThrottlingManager:

Semaphore sendemailjob doesn’t exist. Use ThrottlingManager.AddOrUpdateSemaphore method to add semaphores.

Ah, figured it out. Posting here for anyone else.

JobStorage jobStorage = … // the default storage for ThrottlingManager is JobStorage.Current, in my case I needed a different storage…
IThrottlingManager manager = new ThrottlingManager(jobStorage);
manager.AddOrUpdateSemaphore(“sendemailjob”, new SemaphoreOptions(10));