Skip to content

Commit 5eaffd2

Browse files
committed
Simplify AbpTickerQFunctionProvider and add input validation to AddFunction
1 parent f0228f0 commit 5eaffd2

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

framework/src/Volo.Abp.TickerQ/Volo/Abp/TickerQ/AbpTickerQFunctionProvider.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ public void AddFunction(
2424
TickerTaskPriority priority = TickerTaskPriority.Normal,
2525
int maxConcurrency = 0)
2626
{
27-
Functions.TryAdd(name, (string.Empty, priority, function, maxConcurrency));
27+
Check.NotNullOrWhiteSpace(name, nameof(name));
28+
Check.NotNull(function, nameof(function));
29+
30+
if (maxConcurrency < 0)
31+
{
32+
throw new ArgumentException("maxConcurrency must be greater than or equal to 0.", nameof(maxConcurrency));
33+
}
34+
35+
if (!Functions.TryAdd(name, (string.Empty, priority, function, maxConcurrency)))
36+
{
37+
throw new AbpException($"A function with the name '{name}' is already registered.");
38+
}
2839
}
2940
}

0 commit comments

Comments
 (0)