Skip to content

Commit

Permalink
第一个可用版本
Browse files Browse the repository at this point in the history
实现Web hook触发
邮件外发
服务端脚本执行
  • Loading branch information
ipconfiger committed Dec 29, 2023
1 parent 0410176 commit fda4188
Show file tree
Hide file tree
Showing 8 changed files with 774 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/poulpe_git.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "poulpe"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
axum = "0.6.19"
clap = "3.2.6"
tokio = { version = "1.35.1", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
redis = { version = "0.23", features = ["tokio-comp"] }
chrono = "0.4.19"
cron = "0.5.0"
timer = "0.2.0"
#lettre = "0.10.4"
lettre = { version = "0.10.4", default-features = false, features = ["builder", "smtp-transport", "rustls-tls"] }
dirs = "3.0.2"
reqwest = { version = "0.11.23", default-features = false, features = ["blocking", "json", "rustls-tls"] }

[dev-dependencies]
tokio = { version = "1", features = ["rt", "macros"] }
70 changes: 69 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,70 @@
# poulpe
# poulpe : /pulp/
Light weight easy to use task manager written by Rust

使用Rust实现的轻量级作业管理系统。

支持的作业模式有:

1. 定时任务(秒级粒度)
2. 延迟触发任务
3. 即时触发任务

作业执行的类型支持:

1. HTTP(GET|POST)
2. 邮件
3. 服务端本地脚本

例子:

./poulpe \
--port 8000 #运行的端口
--redis redis://127.0.0.1 #用于持久化作业的redis连接
--cron /etc/cron_task #定义定时任务的文件地址
--dead /tmp/deadpool #死信箱目录,用于存储死任务
--workers 4 #启动工作线程的数量
--retry_interval 10 #错误重试间隔时间
--max_retry 3 #最多重试的次数
--smtp_server xxx.xxx.com #SMTP服务器地址
--smtp_port 23 #SMTP服务器端口
--smtp_name alex #SMTP账号
--smtp_pwd ***** #SMTP密码
--starttls #是否启用starttls


实时触发和延迟触发均通过http接口

curl -X POST http://127.0.0.1:8000/task_in_queue
-H 'Content-Type: application/json'
-d '{...}'

JSON Body的格式如下:

{
"id": "唯一编码",
"method": "作业执行的类型 GET|POST|EXEC|MAIL_TO",
"delay": 0, # 延迟执行的秒数,0为即时触发
"name": "命令名", # GET|POST的时候是请求地址,EXEC为命令名,MAIL_TO为邮件名
"params": "参数", # GET时为QueryString,POST时是JSON字符串,EXEC时为空格隔开的参数,MAIL_TO的时候为专门定义的JSON字符串
"cc": 3, # 支持并行执行的数量,0为不限制
"cf": "test" # 并行标识,相同标识的处于相同的并行队列
}

MAIL_TO 的params的JSON结构

{
"from_addr": "发件地址",
"to_addr": "收件地址",
"title": "邮件标题",
"body": "邮件正文"
}

暂时不支持附件和html

CRON配置文件格式

秒 分 时 日 月 星期 年 命令name medod 参数
1 * * * * * * cmd GET xx xx xx xx

cron不支持MAIL_TO

Loading

0 comments on commit fda4188

Please sign in to comment.