Aicrosoft.Scheduling 6.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Aicrosoft.Scheduling --version 6.2.1
NuGet\Install-Package Aicrosoft.Scheduling -Version 6.2.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="Aicrosoft.Scheduling" Version="6.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Aicrosoft.Scheduling --version 6.2.1
#r "nuget: Aicrosoft.Scheduling, 6.2.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.
// Install Aicrosoft.Scheduling as a Cake Addin
#addin nuget:?package=Aicrosoft.Scheduling&version=6.2.1

// Install Aicrosoft.Scheduling as a Cake Tool
#tool nuget:?package=Aicrosoft.Scheduling&version=6.2.1

SuperJobs

简单的多功能任务调度实现

Aicrosoft.Scheduling

简单的多功能任务调度框架 Keywords: superjobs,task,job,routine,schedule,startup,interval,cronexpression


TODO

  • MonopolyKey 同一时间同一Key的只能运行一个。
  • 同时运行Worker的数量限制。避免太多的Worker同时工作。
  • SomeWorkerPoolProvider 的手动编码能否自动实现呢?

使用说明 How To Use

一个具体的Task三部分组成:

  • SomeJob : Job, ITransient : 必须,它是该Job任务的配置信息,名称,运行时间,等。可以是硬编码,也可以是在Appsettings.json中的配置。
  • SomeWorker : TimerWorker, ITransient :不须一一对应,但是要有给Job可用的。不同类型的Job,如果执行的任务是同一类型的,可以由同样的Worker来运行。
  • SomeWorkerPoolProvider : WorkerPoolProvider<SomeWorker>, ITransient :它与具体的Worker一一对应。池化具体的Worker。

具体的工作负载都是在SomeWorker.ExecuteAsync(CancellationToken)中来完成的。请注意任务的取消,以便急时取消任务。

配置的扩展

  • 每个Job程序集中可以有多个Job,可以有自已的配置文件(不要与其它的程序集里的配置文件名相同即可)。继承JobAppSetupBase重写相关方法即可注册服务类或配置绑定。

关于Woker的使用的注意事项

  • 绝大数多数情况下,不用直接继承Worker。除非该Worker是立即运行;
  • 通过Task.Delay方式运行的方法并没有Timer的调用更高效,所以当前框架使用的是Timer;
  • TimerWorker有很多Protected方法实现了相关事件的调用;
  • 架构没有实现进程或AppDomain的隔离,如果有需要在自定义的Worker中去实现相应的隔离即可。
  • 示例项目 SuperJobsAgent.Console 引入Fody后开发中不能急时生成开发的内容,最好是仅在Release中使用。
  • 示例项目中的公有资源配置及配置的Job信息移除,采用Job程序集中独立配置文件获取(注意不同Job的配置文件不要同名)。

SuperJobs Architecture Design

Architecture Design UML

关于UML上Class创建与依赖的关系说明

  1. Instances are mostly created through DI through their interfaces.
  2. The interface instantiated by DI does not draw the relationship
  3. WorkShop 消费 Worker, WorkerPoolFactory 创建Woker。

关于UML 图及设计说明

  1. Job仅仅是对某一个任务的描述(名称,调度,由哪个Worker来运行等);
  2. Woker是执行Job的任务负载者。
  3. Job由两种已定义的JobProvider创建,这两个JobProvider能通过硬编码和配置设定Job信息,然后能过JobFactory汇总出所有的可用Jobs;
  4. Woker由WokerPoolProvider提供,然后由WokerPoolFactory汇总所有可用的Woker。自定义的Worker必须实现对应的WorkerPoolProvider;

工作要求类型(Worker.RequiredStyles)

  • 该类型与Job的JobTrigger中的Style是有对应关系的;
  • 该属性是个Flag枚举值;
  • 只有Job的Trigger Style符合Worker的RequiredStyles才能调用;

Job的触发器

根据传入的Triger类型来生成触发器

  • Default 通过其它的Woker来触发的Job,当下面的类型未检测到时转视为该类型 (目前没用到)
  • Startup 大于0的延迟启动毫秒数,Int类型的数字 ex:1200 该Worker用完后将被完全释放;
  • Interval 间隔运行的Job,Timespan类型 ex:00:01:00 负载运行时间不被算在间隔时间内 完成后回收到池;
  • Schedulable Cron表达式触发的Job,CronExpresssion表达式 ex:0 0/7 * * * ? 完成后回收到池中;
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on Aicrosoft.Scheduling:

Package Downloads
AutoUpdateJobDemo

Extensions of Aicrosoft Ltd.

AppInsightsTelemetryJob

Extensions of Aicrosoft Ltd.

DDNSJob

Extensions of Aicrosoft Ltd.

PrinergyJob

Extensions of Aicrosoft Ltd.

SuperJobs.Core

Extensions of Aicrosoft Ltd.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.4.0 314 11/20/2023
6.3.2 122 11/1/2023
6.2.1 134 8/25/2023
6.1.7 148 7/25/2023
6.1.6 131 5/17/2023
6.1.5 219 3/13/2023
6.1.4 223 3/11/2023
6.1.3 240 2/21/2023

Ver:6.1.6  2023-03-16 Release Notes:
- Fix some waring in code.
- Add extension method IfNotNullOrEmptyThen to run Action when a string value is not empty
- LogHelper.SetConfigurationVariable replaces old SetNLogConfigVariable (flag not available)
- Increase the execution of If conditions, mark other If methods as expired and be removed
- Added the generation of ReleaseNote