14 releases
0.3.0 | Aug 24, 2023 |
---|---|
0.2.2 | Jul 10, 2023 |
0.2.0 | Jun 30, 2023 |
0.1.10 | Mar 15, 2023 |
0.1.2 | Dec 31, 2022 |
#19 in #flows
6KB
57 lines
This is a library for scheduling your flow function as a cron job in flows.network.
For details, please refer to Schedule Integration.
lib.rs
:
Make flow function acting as scheduled task in Flows.network
Quick Start
To get started, let's write a task that will send a message to Slack at a fixed time wach day.
use schedule_flows::{schedule_cron_job, schedule_handler};
use slack_flows::send_message_to_channel;
#[no_mangle]
#[tokio::main(flavor = "current_thread")]
pub async fn on_deploy() {
schedule_cron_job(String::from("50 8 * * *"), String::from("cron_job_evoked")).await;
}
#[schedule_handler]
async fn handler(body: Vec<u8>) {
send_message_to_channel(
"myworkspace",
"mychannel",
String::from_utf8_lossy(&body).into_owned(),
).await
}
[schedule_cron_job()] will create a cron job. The handler
decorated by macro [schedule_handler]
will be called when the job is evoked at 8:50 UTC each day.
Dependencies
~1–1.7MB
~41K SLoC