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

Download history 26/week @ 2024-01-05 2/week @ 2024-01-12 17/week @ 2024-01-19 17/week @ 2024-02-09 3/week @ 2024-02-16 2/week @ 2024-02-23 17/week @ 2024-03-01 123/week @ 2024-03-08 39/week @ 2024-03-15 2/week @ 2024-03-22 20/week @ 2024-03-29 14/week @ 2024-04-05 157/week @ 2024-04-12 102/week @ 2024-04-19

293 downloads per month

MIT/Apache

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.8MB
~42K SLoC