MCPcopy Index your code
hub / github.com/deciduously/skedge

github.com/deciduously/skedge @v0.3.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.3.0 ↗ · + Follow
151 symbols 389 edges 10 files 54 documented · 36%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

skedge

Crates.io rust action docs.rs

Rust single-process scheduling. Ported from schedule for Python, in turn inspired by clockwork (Ruby), and "Rethinking Cron" by Adam Wiggins.

Usage

Documentation can be found on docs.rs.

This library uses the Builder pattern to define jobs. Instantiate a fresh Scheduler, then use the every() and every_single() functions to begin defining a job. Finalize configuration by calling Job::run() to add the new job to the scheduler. The Scheduler::run_pending() method is used to fire any jobs that have arrived at their next scheduled run time. Currently, precision can only be specified to the second, no smaller.

use jiff::{ToSpan, Zoned};
use skedge::{every, Scheduler};
use std::thread::sleep;
use std::time::Duration;

fn greet(name: &str) {
    let now = Zoned::now();
    println!("Hello {name}, it's {now}!");
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut schedule = Scheduler::new();

    every(2)
        .to(8)?
        .seconds()?
        .until(Zoned::now().checked_add(30.seconds()).unwrap())?
        .run_one_arg(&mut schedule, greet, "Cool Person")?;

    let now = Zoned::now();
    println!("Starting at {now}");
    loop {
        if let Err(e) = schedule.run_pending() {
            eprintln!("Error: {e}");
        }
        sleep(Duration::from_secs(1));
    }
}

Check out the example script to see more configuration options. Try cargo run --example readme or cargo run --example basic to see it in action.

CFFI

There is an experimental C foreign function interface, which is feature-gated and not included by default. To build the library with this feature, use cargo build --features ffi. See the Makefile and examples/ffi/c directory for details on using this library from C. Execute make run to build and execute the included example C program. It currently only supports work functions which take no arguments.

Development

Clone this repo. See CONTRIBUTING.md for contribution guidelines.

Dependencies

  • Stable Rust: The default stable toolchain is fine. Obtainable via rustup using the instructions at this link.

Crates

Development-Only

Extension points exported contracts — how you extend this code

Callable (Interface)
A job is anything that implements this trait [8 implementers]
src/callable.rs
Timekeeper (Interface)
(no doc) [3 implementers]
src/time.rs

Core symbols most depended-on inside this repo

run
called by 18
src/job.rs
seconds
called by 18
src/job.rs
every_single
called by 13
src/job.rs
run_pending
called by 11
src/scheduler.rs
every
called by 10
src/job.rs
minute
called by 10
src/job.rs
schedule_next_run
called by 9
src/job.rs
now
called by 9
examples/ffi/c/main.c

Shape

Method 72
Function 60
Class 14
Enum 3
Interface 2

Languages

Rust96%
C4%

Modules by API surface

src/job.rs61 symbols
src/ffi.rs28 symbols
src/scheduler.rs21 symbols
src/callable.rs14 symbols
src/time.rs10 symbols
src/error.rs6 symbols
examples/ffi/c/main.c6 symbols
examples/basic.rs3 symbols
examples/readme.rs2 symbols

For agents

$ claude mcp add skedge \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact