ScheduleTaskHelper.Infrastructure
1.0.7
dotnet add package ScheduleTaskHelper.Infrastructure --version 1.0.7
NuGet\Install-Package ScheduleTaskHelper.Infrastructure -Version 1.0.7
<PackageReference Include="ScheduleTaskHelper.Infrastructure" Version="1.0.7" />
<PackageVersion Include="ScheduleTaskHelper.Infrastructure" Version="1.0.7" />
<PackageReference Include="ScheduleTaskHelper.Infrastructure" />
paket add ScheduleTaskHelper.Infrastructure --version 1.0.7
#r "nuget: ScheduleTaskHelper.Infrastructure, 1.0.7"
#:package ScheduleTaskHelper.Infrastructure@1.0.7
#addin nuget:?package=ScheduleTaskHelper.Infrastructure&version=1.0.7
#tool nuget:?package=ScheduleTaskHelper.Infrastructure&version=1.0.7
ScheduleTaskHelper.Infrastructure
ScheduleTaskHelper.Infrastructure is a robust task scheduling and execution framework designed for .NET applications. It supports various task scheduling modes (including timed and Cron expressions) and integrates distributed lock mechanisms, task retry queues, and event-driven architecture to ensure reliable and efficient task execution. Additionally, the framework supports a plugin-based architecture, allowing dynamic loading of external plugins, making it suitable for distributed systems or applications requiring efficient task management.
Features
- Distributed Lock Mechanisms: Provides Redis-based and in-memory distributed lock implementations to ensure safe execution across multiple nodes.
- Task Scheduling: Includes interfaces and utilities for defining and executing scheduled tasks.
- Retry Queues: Supports task retry mechanisms for handling failures.
- Event-Driven Architecture: Enables event-based task execution and monitoring.
- Plugin Architecture: Allows dynamic loading and management of external plugins.
Key Components
Locks
- RedisDistributedLockProvider: Implements distributed locks using Redis.
- InMemoryDistributedLockProvider: Provides an in-memory implementation of distributed locks for simpler use cases.
- RedisLockOptions: Configuration options for Redis-based locks.
Tasks
- IScheduledTask: Interface for defining scheduled tasks with properties like name, group, priority, and execution logic.
- ICronScheduledTask: Extends
IScheduledTask
to support Cron-based scheduling.
Rules
- IRules: Interface for defining validation rules for tasks.
Reports
- IReport: Interface for generating reports from tasks.
Utilities
- BatchProcessingUtils: Utility class for batch processing tasks.
Cache
- CacheManager: Provides caching capabilities for task management.
Getting Started
Prerequisites
- .NET 8.0 SDK
- Redis (if using
RedisDistributedLockProvider
)
Installation
- Clone the repository.
- Navigate to the
ScheduleTaskHelper.Infrastructure
project directory. - Build the project using the .NET CLI:
dotnet build
Usage
Define a Task
Implement the IScheduledTask
or ICronScheduledTask
interface to define your task logic:
public class MyTask : IScheduledTask
{
public string Name => "MyTask";
public string Group => "Default";
public TimeSpan InitialDelay => TimeSpan.FromSeconds(10);
public TimeSpan Period => TimeSpan.FromMinutes(1);
public int Priority => 1;
public Task<int> Execute()
{
Console.WriteLine("Executing MyTask");
return Task.FromResult(0);
}
public void Stop()
{
Console.WriteLine("Stopping MyTask");
}
}
Use Distributed Locks
Configure and use the RedisDistributedLockProvider
or InMemoryDistributedLockProvider
:
var redisLockProvider = new RedisDistributedLockProvider(redisConnection, options);
var distributedLock = await redisLockProvider.AcquireLockAsync("resourceName", "owner", TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(10));
if (distributedLock != null)
{
// Perform critical section
await distributedLock.ReleaseAsync();
}
Contributing
Contributions are welcome! Please fork the repository and submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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 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 is compatible. 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. |
-
net7.0
- Autofac.Extensions.DependencyInjection (>= 10.0.0)
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- NLog.Extensions.Logging (>= 5.5.0)
- StackExchange.Redis (>= 2.8.58)
-
net8.0
- Autofac.Extensions.DependencyInjection (>= 10.0.0)
- Microsoft.Extensions.Caching.Memory (>= 9.0.8)
- NLog.Extensions.Logging (>= 5.5.0)
- StackExchange.Redis (>= 2.8.58)
-
net9.0
- Autofac.Extensions.DependencyInjection (>= 10.0.0)
- Microsoft.Extensions.Caching.Memory (>= 9.0.8)
- NLog.Extensions.Logging (>= 5.5.0)
- StackExchange.Redis (>= 2.8.58)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on ScheduleTaskHelper.Infrastructure:
Package | Downloads |
---|---|
ScheduleTaskHelper.Plugins
ScheduleTaskHelper.Plugins 是一個專為 .NET 應用程式設計的插件式架構框架,提供動態載入與管理外部插件的能力。此框架支援插件的初始化、服務註冊、任務管理與卸載,並透過標準化的介面與基底類別,簡化插件的開發與整合。適用於需要高擴展性與模組化設計的應用場景。 |
|
ScheduleTaskHelper.Tasks
ScheduleTaskHelper.Tasks 是一個專為 .NET 應用程式設計的任務排程框架,提供多種任務排程模式,包括定時任務與 Cron 表達式排程。此框架支援任務優先級管理、執行狀態追蹤與重試機制,並可與插件架構無縫整合,適用於需要高效任務管理的應用場景。 |
GitHub repositories
This package is not used by any popular GitHub repositories.