Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JobCount method to MonitoringApi to get count of jobs in any state #2182

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Issung
Copy link

@Issung Issung commented Mar 24, 2023

Currently monitoring API only supports getting job count for the given states (e.g. processing, scheduled, failed)
Useful for developers who create jobs with custom states.
Signed commits now.

@Issung
Copy link
Author

Issung commented Mar 24, 2023

I realise you have a redis storage and preview memory storage too that this would need implementing on. Given it is a reasonably simple function I hope you can do it quickly and easily, if you would prefer I do it where can I access those classes to make another PR matching this one?

@burningice2866
Copy link
Contributor

... and I have a Storage provider for a specific CMS and there are MySQL and mongoddb and many other storage providers out there.

So no changing of public interfaces, it break things.

@Qubitus
Copy link

Qubitus commented Aug 11, 2023

I agree with the need for this after having implemented our own custom states recently.
As mentioned, adding this method to the interface would break existing storage provider implementations.
You could avoid this with a default interface implementation, but that's only available in .NETCore 3.0/C# 8.0.

A workaround for now could be to add a default implementation (which just throws a NotImplementedException instance) to the JobStorageMonitor base abstract class.
That way storage providers based on this class can override the method and provide a concrete implementation if they want. Casting the IMonitoringApi to JobStorageMonitor would then allow you to use this method.
Not a perfect solution by any means, but would slightly improve the experience of working with custom states.

@Issung
Copy link
Author

Issung commented Aug 12, 2023

I like that Idea @Qubitus, I will update the PR soon with that change.
As for @burningice2866 's comment, breaking changes are a necessity to improve APIs. If Hangfire itself has a breaking change promise, then this change can be held for a major version number release.

Copy link

sonarcloud bot commented Dec 4, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants