From bc975893a6a5df5155d427da09a7d8bb658f850e Mon Sep 17 00:00:00 2001 From: Aistis Olendra Date: Fri, 3 Feb 2023 13:25:52 +0200 Subject: [PATCH] Change parameter type, introduce exception for 0 length --- src/Hangfire.Core/Storage/IMonitoringApi.cs | 2 +- src/Hangfire.Core/Storage/JobStorageMonitor.cs | 2 +- src/Hangfire.SqlServer/SqlServerMonitoringApi.cs | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Hangfire.Core/Storage/IMonitoringApi.cs b/src/Hangfire.Core/Storage/IMonitoringApi.cs index cd10f2fe3..80402b10f 100644 --- a/src/Hangfire.Core/Storage/IMonitoringApi.cs +++ b/src/Hangfire.Core/Storage/IMonitoringApi.cs @@ -31,7 +31,7 @@ public interface IMonitoringApi JobList ProcessingJobs(int from, int count); JobList ScheduledJobs(int from, int count); - JobList ScheduledJobsByIds(IEnumerable jobIds); + JobList ScheduledJobsByIds(long[] jobIds); JobList SucceededJobs(int from, int count); JobList FailedJobs(int from, int count); JobList DeletedJobs(int from, int count); diff --git a/src/Hangfire.Core/Storage/JobStorageMonitor.cs b/src/Hangfire.Core/Storage/JobStorageMonitor.cs index 82a3c3499..fa970e18c 100644 --- a/src/Hangfire.Core/Storage/JobStorageMonitor.cs +++ b/src/Hangfire.Core/Storage/JobStorageMonitor.cs @@ -30,7 +30,7 @@ public abstract class JobStorageMonitor : IMonitoringApi public abstract JobList FetchedJobs(string queue, int from, int perPage); public abstract JobList ProcessingJobs(int from, int count); public abstract JobList ScheduledJobs(int from, int count); - public abstract JobList ScheduledJobsByIds(IEnumerable jobIds); + public abstract JobList ScheduledJobsByIds(long[] jobIds); public abstract JobList SucceededJobs(int from, int count); public abstract JobList FailedJobs(int from, int count); public abstract JobList DeletedJobs(int from, int count); diff --git a/src/Hangfire.SqlServer/SqlServerMonitoringApi.cs b/src/Hangfire.SqlServer/SqlServerMonitoringApi.cs index 738fda904..018af0876 100644 --- a/src/Hangfire.SqlServer/SqlServerMonitoringApi.cs +++ b/src/Hangfire.SqlServer/SqlServerMonitoringApi.cs @@ -114,8 +114,11 @@ public override JobList ScheduledJobs(int @from, int count) })); } - public override JobList ScheduledJobsByIds(IEnumerable jobIds) + public override JobList ScheduledJobsByIds(long[] jobIds) { + if (jobIds.Length == 0) + throw new InvalidOperationException("Sequence contains no elements"); + return UseConnection(connection => GetJobsByIdsList( connection, jobIds, @@ -646,7 +649,7 @@ private JobList GetJobs( private JobList GetJobsByIdsList( DbConnection connection, - IEnumerable jobIds, + long[] jobIds, string stateName, Func, TDto> selector) {