ToolWheel.Extensions.JobManager.Conditions
1.0.0
dotnet add package ToolWheel.Extensions.JobManager.Conditions --version 1.0.0
NuGet\Install-Package ToolWheel.Extensions.JobManager.Conditions -Version 1.0.0
<PackageReference Include="ToolWheel.Extensions.JobManager.Conditions" Version="1.0.0" />
<PackageVersion Include="ToolWheel.Extensions.JobManager.Conditions" Version="1.0.0" />
<PackageReference Include="ToolWheel.Extensions.JobManager.Conditions" />
paket add ToolWheel.Extensions.JobManager.Conditions --version 1.0.0
#r "nuget: ToolWheel.Extensions.JobManager.Conditions, 1.0.0"
#:package ToolWheel.Extensions.JobManager.Conditions@1.0.0
#addin nuget:?package=ToolWheel.Extensions.JobManager.Conditions&version=1.0.0
#tool nuget:?package=ToolWheel.Extensions.JobManager.Conditions&version=1.0.0
ToolWheel.Extensions.JobManager.ExecutionConditions
Pre-execution condition evaluators for the ToolWheel Job Manager. Ships conditions that prevent a job from running when its task limit is reached, when a dependency job is still active, or when the configured rate limit is exceeded.
Package Info
| Property | Value |
|---|---|
| Target Framework | net8.0; net10.0 |
| NuGet Package ID | ToolWheel.Extensions.JobManager.ExecutionConditions |
| Project Reference | ToolWheel.Extensions.JobManager.Abstractions |
Auto Configuration
This package ships JobManagerExecutionConditionModule implementing IJobManagerModulDescription. When AddJobManager() scans loaded assemblies at startup it automatically:
- Registers
IJobRateLimitTrackeras a singleton implementation ofJobRateLimitTracker. - Adds
JobTaskLimiterConditionas anIExecutionCondition. - Adds
JobDependencyConditionas anIExecutionCondition. - Adds
JobRateLimitConditionas anIExecutionCondition. - Adds
JobRateLimitMiddlewareto the execution pipeline.
No manual registration is required � referencing the package is sufficient.
Task Limit
Prevents a job from creating new tasks when the configured maximum number of concurrent pending or running tasks is already reached.
Configuration
jobs.Add("import-job", worker.RunImport)
.Name("Data Import")
.Enabled()
.TaskLimit(3); // at most 3 concurrent tasks
A limit of 0 or null means no limit is enforced.
How It Works
- When a job is configured with
.TaskLimit(count), theJobTaskLimitFeatureis applied viaIJobExecutionConditionService.Add<JobTaskLimitFeature>(). - Before each execution,
JobTaskLimiterConditionretrieves the feature and counts active tasks (statusPendingorRunning) viaIJobTaskService.ReadByJob(job, ...). - If the count >= limit, the execution context is set to not ready with the message
"Task limit reached".
Job Execution Dependencies
Prevents a job from starting while one or more other jobs still have active (Pending or Running) tasks.
Configuration
jobs.Add("import-job", worker.ImportData)
.Name("Data Import")
.Enabled();
jobs.Add("cleanup-job", worker.Cleanup)
.Name("Cleanup")
.Enabled()
.DependsOn("import-job"); // blocked while import-job is active
Multiple dependencies and combinations with other conditions are supported:
jobs.Add("report-job", worker.GenerateReport)
.Name("Report")
.Enabled()
.TaskLimit(1)
.DependsOn("import-job", "sync-job");
How It Works
- When a job is configured with
.DependsOn(jobIds), theJobDependencyFeatureis applied viaIJobExecutionConditionService.Add<JobDependencyFeature>(). - Before each execution,
JobDependencyConditioniterates the registered dependency job IDs. - For each dependency, it resolves the job instance via
IJobService.FindById()and queries active tasks viaIJobTaskService.ReadByJob(dep, Pending, Running). - If any dependency has at least one active task, the execution context is set to not ready with the message
"A dependent job is still running"and evaluation stops early.
Rate Limiting
Prevents a job from being started too frequently within a rolling time window.
Configuration
jobs.Add("api-sync-job", worker.SyncWithApi)
.Name("API Sync")
.Enabled()
.RateLimit(maxStarts: 10, timeWindow: TimeSpan.FromHours(1));
Combine with other conditions:
jobs.Add("heavy-job", worker.ProcessHeavyWork)
.Name("Heavy Job")
.Enabled()
.TaskLimit(1)
.RateLimit(maxStarts: 5, timeWindow: TimeSpan.FromMinutes(10));
A maxStarts of 0 or less disables rate limiting for the job. The time window is rolling (continuous), not fixed intervals.
How It Works
- When a job is configured with
.RateLimit(maxStarts, timeWindow), theJobRateLimitFeatureis applied viaIJobExecutionConditionService.Add<JobRateLimitFeature>(). - Before each execution,
JobRateLimitConditionretrieves the feature and callsIJobRateLimitTracker.CanStart(job, feature)to check if the job can be started within the rolling window. - If the number of starts within the window has reached the limit, the execution context is set to not ready with the message
"Rate limit reached". - When a task is about to start,
JobRateLimitMiddlewarerecords the start time viaIJobRateLimitTracker.RecordStart(job). - The tracker automatically purges start times that fall outside the rolling window when evaluating
CanStart().
API Reference
Extension Methods (IJobDescriptionBuilder)
| Method | Description |
|---|---|
.TaskLimit(int count) |
Limits the number of concurrently running tasks for the job. |
.DependsOn(params string[] jobIds) |
Blocks the job while any of the specified jobs are still active. |
.RateLimit(int maxStarts, TimeSpan timeWindow) |
Limits how many times the job can be started within a rolling time window. |
Services & Extension Methods
IJobExecutionConditionService Extension Methods
| Method | Parameters | Description |
|---|---|---|
SetTaskLimit(job, count) |
IJob, int? |
Stores the task limit for a job; null removes it. |
GetTaskLimit(job) |
IJob |
Returns the configured task limit or null. |
SetDependencies(job, dependsOnJobIds) |
IJob, IEnumerable<string> |
Registers dependency job IDs for a job. |
GetDependencyJobIds(job) |
IJob |
Returns the set of dependency job IDs. |
SetRateLimit(job, maxStarts, timeWindow) |
IJob, int, TimeSpan |
Configures rate limiting for a job. |
GetRateLimit(job) |
IJob |
Returns the configured rate-limit feature or null. |
IJobRateLimitTracker
| Interface | Implementation | Description |
|---|---|---|
IJobRateLimitTracker |
JobRateLimitTracker |
In-memory tracker for job start times; automatically purges expired entries. |
Conditions
| Type | Blocks when |
|---|---|
JobTaskLimiterCondition |
Active task count >= configured limit. |
JobDependencyCondition |
A dependency job has Pending or Running tasks. |
JobRateLimitCondition |
Number of starts within the time window >= configured limit. |
Middleware
| Type | Purpose |
|---|---|
JobRateLimitMiddleware |
Records each job start time for rate-limit accounting. |
Features
| Type | Stores |
|---|---|
JobTaskLimitFeature |
Configured task limit. |
JobDependencyFeature |
Declared dependency job IDs. |
JobRateLimitFeature |
Rate-limit configuration (max starts + time window). |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- ToolWheel.Extensions.JobManager.Abstractions (>= 1.0.0 && < 2.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 107 | 6/6/2026 |