Sparkdo.BackgroundJobs
1.0.1
.NET 10.0
This package targets .NET 10.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Sparkdo.BackgroundJobs --version 1.0.1
NuGet\Install-Package Sparkdo.BackgroundJobs -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sparkdo.BackgroundJobs" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sparkdo.BackgroundJobs" Version="1.0.1" />
<PackageReference Include="Sparkdo.BackgroundJobs" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Sparkdo.BackgroundJobs --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Sparkdo.BackgroundJobs, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Sparkdo.BackgroundJobs@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Sparkdo.BackgroundJobs&version=1.0.1
#tool nuget:?package=Sparkdo.BackgroundJobs&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Sparkdo.BackgroundJobs
Sparkdo 后台作业库,提供后台任务调度和执行功能实现。
功能特性
- 后台作业调度和执行
- 支持作业优先级设置
- 支持作业失败重试机制
- 支持分布式锁确保作业执行唯一性
- 支持作业延迟执行
- 内存存储实现(可替换为其他存储实现)
- 与 Sparkdo 框架无缝集成
安装
<PackageReference Include="Sparkdo.BackgroundJobs" Version="x.x.x" />
核心组件
DefaultBackgroundJobManager
默认后台作业管理器实现,负责将作业添加到存储中以便后续执行:
EnqueueAsync(): 将指定参数的作业加入执行队列
DefaultBackgroundJobWorker
默认后台作业工作器实现,负责从存储中获取等待执行的作业并执行它们:
- 定期轮询等待执行的作业
- 使用分布式锁确保同一时间只有一个工作器在处理作业
- 执行作业并处理成功或失败的情况
- 支持作业失败重试机制
InMemoryBackgroundJobStore
内存后台作业存储实现,使用内存字典存储后台作业信息:
- 提供作业的增删改查功能
- 支持获取等待执行的作业列表
JsonBackgroundJobSerializer
JSON 后台作业序列化器实现,使用 Sparkdo JSON 序列化服务进行作业参数的序列化和反序列化。
配置选项
SparkdoBackgroundJobWorkerOptions
后台作业工作器配置选项:
ApplicationName: 应用程序名称JobPollPeriod: 轮询作业间隔(毫秒)MaxJobFetchCount: 单次获取作业最大数量DefaultFirstWaitDuration: 故障第一次等待时间(秒)DefaultTimeout: 作业超时时间(秒)DefaultWaitFactor: 执行失败等待因子DistributedLockName: 分布式锁名称
SparkdoBackgroundJobOptions
后台作业配置选项:
IsJobExecutionEnabled: 是否启用作业执行AddJob(): 添加作业配置
扩展性
该库提供了完整的后台作业功能实现,可以通过以下方式扩展:
- 实现自定义的
IBackgroundJobStore来替换默认的内存存储实现 - 实现自定义的
IBackgroundJobSerializer来处理特定的序列化需求 - 通过
SparkdoBackgroundJobWorkerOptions配置工作器行为 - 通过
SparkdoBackgroundJobOptions配置作业行为
代码结构说明
本项目包含以下主要组件:
后台作业管理
IBackgroundJobManager: 后台作业管理器接口DefaultBackgroundJobManager: 默认后台作业管理器实现
后台作业执行
IBackgroundJobWorker: 后台作业工作器接口DefaultBackgroundJobWorker: 默认后台作业工作器实现IBackgroundJobExecuter: 后台作业执行器接口DefaultBackgroundJobExecuter: 默认后台作业执行器实现
后台作业存储
IBackgroundJobStore: 后台作业存储接口InMemoryBackgroundJobStore: 内存后台作业存储实现
序列化
IBackgroundJobSerializer: 后台作业序列化器接口JsonBackgroundJobSerializer: JSON 后台作业序列化器实现
配置
SparkdoBackgroundJobOptions: 后台作业配置选项SparkdoBackgroundJobWorkerOptions: 后台作业工作器配置选项SparkdoBackgroundJobsModule: 后台作业模块配置
所有公共接口和类都添加了详细的 XML 文档注释,便于开发者理解和使用。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 is compatible. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- JetBrains.Annotations (>= 2025.2.2)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.0)
- Microsoft.Extensions.Configuration (>= 10.0.0)
- Microsoft.Extensions.Configuration.CommandLine (>= 10.0.0)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.0)
- Microsoft.Extensions.Configuration.FileExtensions (>= 10.0.0)
- Microsoft.Extensions.Configuration.Json (>= 10.0.0)
- Microsoft.Extensions.Configuration.UserSecrets (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.DependencyModel (>= 10.0.0)
- Microsoft.Extensions.FileProviders.Composite (>= 10.0.0)
- Microsoft.Extensions.FileProviders.Embedded (>= 10.0.0)
- Microsoft.Extensions.FileProviders.Physical (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Localization (>= 10.0.0)
- Microsoft.Extensions.Logging (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.0)
- Nito.AsyncEx.Context (>= 5.1.2)
- Sparkdo.BackgroundJobs.Abstractions (>= 1.0.1)
- Sparkdo.BackgroundWorkers (>= 1.0.1)
- Sparkdo.DistributedLocking.Abstractions (>= 1.0.1)
- Sparkdo.IdGeneration (>= 1.0.1)
- Sparkdo.Json (>= 1.0.1)
- Sparkdo.Timing (>= 1.0.1)
- System.Linq.Dynamic.Core (>= 1.7.0)
- System.Runtime.Loader (>= 4.3.0)
- System.Text.Json (>= 10.0.0)
- TimeZoneConverter (>= 7.2.0)
-
net10.0
- JetBrains.Annotations (>= 2025.2.2)
- Microsoft.Extensions.Configuration (>= 10.0.0)
- Microsoft.Extensions.Configuration.CommandLine (>= 10.0.0)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 10.0.0)
- Microsoft.Extensions.Configuration.FileExtensions (>= 10.0.0)
- Microsoft.Extensions.Configuration.Json (>= 10.0.0)
- Microsoft.Extensions.Configuration.UserSecrets (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.DependencyModel (>= 10.0.0)
- Microsoft.Extensions.FileProviders.Composite (>= 10.0.0)
- Microsoft.Extensions.FileProviders.Embedded (>= 10.0.0)
- Microsoft.Extensions.FileProviders.Physical (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Localization (>= 10.0.0)
- Microsoft.Extensions.Logging (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.0)
- Nito.AsyncEx.Context (>= 5.1.2)
- Sparkdo.BackgroundJobs.Abstractions (>= 1.0.1)
- Sparkdo.BackgroundWorkers (>= 1.0.1)
- Sparkdo.DistributedLocking.Abstractions (>= 1.0.1)
- Sparkdo.IdGeneration (>= 1.0.1)
- Sparkdo.Json (>= 1.0.1)
- Sparkdo.Timing (>= 1.0.1)
- System.Linq.Dynamic.Core (>= 1.7.0)
- TimeZoneConverter (>= 7.2.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Sparkdo.BackgroundJobs:
| Package | Downloads |
|---|---|
|
Sparkdo.BackgroundJobs.TickerQ
Sparkdo TickerQ 后台作业库,提供基于 TickerQ 的后台作业功能集成实现 |
|
|
Sparkdo.BackgroundJobs.Domain
Sparkdo 后台作业领域层,提供后台作业管理的核心业务逻辑和数据访问接口 |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.2-preview.3 | 41 | 2/1/2026 |
| 1.0.2-preview.2 | 43 | 1/31/2026 |
| 1.0.2-preview.1 | 163 | 12/4/2025 |
| 1.0.1 | 263 | 11/27/2025 |
| 1.0.0 | 253 | 11/25/2025 |
| 1.0.0-preview.5 | 114 | 10/24/2025 |