_______ ___
___ ________ ____ __/_ __(_)_ _ ___ ____/ _ \
/ _ `/ __/ _ `/ _ \/ -_) / / / ' \/ -_) __/ , _/
\_, /_/ \_,_/ .__/\__/_/ /_/_/_/_/\__/_/ /_/|_|
/___/ /_/ grapeTimerR
简介 Intro
A coarse-grained time scheduler can help you create time tasks quickly and simply through some series.
一款粗粒度的时间调度器,可以帮你通过一些字符串快速并简单的创建时间任务。
grapeTimer的Rust版本,提供相同功能以及相同类型的服务。
功能 Feature
- 纯异步的代码执行(Pure async code)
- 通过命令格式创建
std::chrono::Datetime
(Created by date format) - 简洁的Api格式,轻度且可拆分的函数库(Simple Api, light and detachable library)
- 快速创建调度器(Quickly create a scheduler)
- 可控的调度器时间粒度
[需要提前指定]
(Controllable scheduler time granularity[Need to specify in advance]
) - 多线程调度模式(Multi-thread scheduling mode)
- 时间周期,次数多模式可控
[支持每天、每周、每月]
(Time period, multi-mode controllable number of times[support daily, weekly, monthly]
) - 可以获取下一次执行时间
[Chrono Datetime]
(Can get the string of the next execution time) - 自定义起始TimerId的种子(Customize the seed of the starting TimerId)
- 自定义TimerId的生成函数
[自生成ID请注意并发场景下的线程争抢]
(Custom TimerId generation trait[Self-generated ID, please pay attention to thread contention in concurrent scenarios]
) - TimerId扩展为i64,支持大ID和timestampId生成器(TimerId is i64, supporting large Id and timestampId generator correspondence)
日期格式 Date Format
The scheduler has a light date pattern analysis system, which can provide daily, weekly, and monthly time and date generation methods
调度器有轻度的日期模式分析体系,可提供每日,每周,每月的时间日期生成方式,具体格式如下:
关键字 Key | 格式 Format | 说明 Description |
---|---|---|
Day | Day 00:00:00 | 生成每日的日期时间 |
Week | Week 1 00:00:00 | 生成每周的日期时间, 0~6 分别代表周日到周六 |
Month | Month 1 00:00:00 | 生成每月该日期的时间,建议不要使用28日之后的日期 |
Key | Format | Description |
---|---|---|
Day | Day 00:00:00 | Generate daily date and time |
Week | Week 1 00:00:00 | Generate weekly date and time, 0~6 represent Sunday to Saturday |
Month | Month 1 00:00:00 | The time when the date of the month was generated, it is recommended not to use the date after the 28th |
Examples
parser date format
use parsers;
// get next tick Datetime
let next_day = parser_next.unwrap;
// get next timestamp
let next_dayTime = parser_timestamp.unwrap;
// utc
let next_dayUtc = parser_nextUtc.unwrap;
let next_dayTimeUtc = parser_timestampUtc.unwrap;
init system
use ;
let conf = Config;
init_schedule;
add ticker
// 使用函数方式执行代码 Use function to execute code
spawn_ticker;
// 使用闭包模式 Use closure function
spawn_ticker;
add ticker by trait mode
// 首先我们定义一个结构体
//First we define a struct
// 使用trait任务,可以简化部分实际逻辑
// Using trait tasks can simplify part of the actual logic
spawn_trait;
add date
;
spawn_date
鸣谢(Thanks)
Use Jetbrains Ide for project