Skip to content

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

Open
Issung wants to merge 1 commit into
HangfireIO:mainfrom
Issung:feature/monitoring-get-jobcount-by-name-2
Open

Add JobCount method to MonitoringApi to get count of jobs in any state#2182
Issung wants to merge 1 commit into
HangfireIO:mainfrom
Issung:feature/monitoring-get-jobcount-by-name-2

Conversation

@Issung

@Issung Issung commented Mar 24, 2023

Copy link
Copy Markdown

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

Issung commented Mar 24, 2023

Copy link
Copy Markdown
Author

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
Copy Markdown
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

Qubitus commented Aug 11, 2023

Copy link
Copy Markdown

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

Issung commented Aug 12, 2023

Copy link
Copy Markdown
Author

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.

@sonarqubecloud

sonarqubecloud Bot commented Dec 4, 2023

Copy link
Copy Markdown

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