Rust single-process scheduling. Ported from schedule for Python

Overview

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.

Result<(), Box > { let mut schedule = Scheduler::new(); every(2) .to(8)? .seconds()? .until(Local::now() + chrono::Duration::seconds(30))? .run_one_arg(&mut schedule, greet, "Good-Looking")?; println!("Starting at {}", Local::now()); loop { if let Err(e) = schedule.run_pending() { eprintln!("Error: {}", e); } sleep(Duration::from_secs(1)); } } ">
use chrono::Local;
use skedge::{every, Scheduler};
use std::thread::sleep;
use std::time::Duration;

fn greet(name: &str) {
    println!("Hello {}, it's {}!", name, Local::now().to_rfc2822());
}

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

    every(2)
        .to(8)?
        .seconds()?
        .until(Local::now() + chrono::Duration::seconds(30))?
        .run_one_arg(&mut schedule, greet, "Good-Looking")?;

    println!("Starting at {}", Local::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

You might also like...
Wealthy Rich ported to Rust! This aims to be a crate for rich text and beautiful formatting in the terminal

Wealthy Rich ported to Rust! This aims to be a crate for rich text and beautiful formatting in the terminal

A fast R-tree for Rust. Ported from an implementation that's designed for Tile38.
A fast R-tree for Rust. Ported from an implementation that's designed for Tile38.

rtree.rs A fast R-tree for Rust. Ported from an implementation that's designed for Tile38. Features Optimized for fast inserts and updates. Ideal for

A simple thread schedule and priority library for rust

thread-priority A simple library to control thread schedule policies and thread priority. If your operating system isn't yet supported, please, create

Stable Diffusion v1.4 ported to Rust's burn framework
Stable Diffusion v1.4 ported to Rust's burn framework

Stable-Diffusion-Burn Stable-Diffusion-Burn is a Rust-based project which ports the V1 stable diffusion model into the deep learning framework, Burn.

Stable Diffusion XL ported to Rust's burn framework
Stable Diffusion XL ported to Rust's burn framework

Stable-Diffusion-XL-Burn Stable-Diffusion-XL-Burn is a Rust-based project which ports stable diffusion xl into the Rust deep learning framework burn.

This repo contains the schedule for summer paper meetup

21' Summer 💙 Paper Meetup Annoucement 📢 6/21/2021: our first summer love paper meetup will start on July 10th, 2021. Papers to contribute 🥂 Check o

A contract to lock fungible tokens with a given vesting schedule including cliffs.

Fungible Token Lockup contract Features A reusable lockup contract for a select fungible token. Lockup schedule can be set as a list of checkpoints wi

🎦 ezz is a simple CLI tool to schedule Zoom meetings

ezz ezz (cheesy abbreviation for easy Zoom) is a simple CLI tool to schedule Zoom meetings. Install With cargo installed: $ cargo install --path . Aut

Get your loadshedding schedule in your calendar and never be left in the dark! Open-source, up-to-date, and developer friendly.
Get your loadshedding schedule in your calendar and never be left in the dark! Open-source, up-to-date, and developer friendly.

Loadshedding schedules in your digital calendar. No apps, no ads, up-to-date, and developer friendly. Get it • Key Features • Using the data • Project

A simple helper to run cronjobs (at repeated schedule) in Bevy.

bevy_cronjob bevy_cronjob is a simple helper to run cronjobs (at repeated schedule) in Bevy. Usage use std::time::Duration; use bevy::{ MinimalPlugins

Spider ported to Node.js

spider-rs The spider project ported to Node.js Getting Started npm i @spider-rs/spider-rs --save import { Website, pageTitle } from "@spider-rs/spider

secmem-proc is a crate designed to harden a process against low-privileged attackers running on the same system trying to obtain secret memory contents of the current process.

secmem-proc is a crate designed to harden a process against low-privileged attackers running on the same system trying to obtain secret memory contents of the current process. More specifically, the crate disables core dumps and tries to disable tracing on unix-like OSes.

A single-producer single-consumer Rust queue with smart batching

Batching Queue A library that implements smart batching between a producer and a consumer. In other words, a single-producer single-consumer queue tha

Single-reader, multi-writer & single-reader, multi-verifier; broadcasts reads to multiple writeable destinations in parallel

Bus Writer This Rust crate provides a generic single-reader, multi-writer, with support for callbacks for monitoring progress. It also provides a gene

Handoff is an unbuffered, single-producer / single-consumer, async channel

handoff handoff is a single-producer / single-consumer, unbuffered, asynchronous channel. It's intended for cases where you want blocking communicatio

Generate a Python module from a single Rust file.

cargo-single-pyo3 Utility to build Python modules from a single Rust files via pyo3. Inspired by cargo-single. Installation cargo install cargo-single

Msgpack serialization/deserialization library for Python, written in Rust using PyO3, and rust-msgpack. Reboot of orjson. msgpack.org[Python]

ormsgpack ormsgpack is a fast msgpack library for Python. It is a fork/reboot of orjson It serializes faster than msgpack-python and deserializes a bi

Rust Imaging Library's Python binding: A performant and high-level image processing library for Python written in Rust

ril-py Rust Imaging Library for Python: Python bindings for ril, a performant and high-level image processing library written in Rust. What's this? Th

Create a Python project automatically with rust (like create-react-app but for python)

create-python-project Create a Python project automatically with rust (like create-react-app but for python) Installation cargo install create-python-

Comments
  • MVP

    MVP

    This version should:

    • Execute all example code
    • Accept jobs taking no parameters, returning no data
    • Contain integration tests for all documented functionality
    opened by deciduously 1
  • CFFI work functions with parameters

    CFFI work functions with parameters

    Can't use generic arguments, the compiler cannot possibly monomorphize. However, void * is a thing, might be the ticket. C is super unsafe anyway...

    enhancement 
    opened by deciduously 0
Releases(0.1.3)
Owner
Ben Lovy
Rust is pretty cool.
Ben Lovy
Task runner and process manager for Rust

Steward Task runner and process manager for Rust. If you're not happy managing your infrastructure with a pile of bash scripts, this crate might be he

Alex Fedoseev 24 Dec 26, 2022
Ergo is a low-code IFTTT/Zapier style application, built with Rust and Svelte

Ergo is a low-code IFTTT/Zapier style application, built with Rust and Svelte. Tasks are customizable with Javascript and can contain state machines for more advanced task handling.

Daniel Imfeld 100 Dec 26, 2022
Fang - Background job processing library for Rust.

Fang Background job processing library for Rust. Currently, it uses Postgres to store state. But in the future, more backends will be supported.

Ayrat Badykov 421 Dec 28, 2022
Rust library to ease the task of creating daemons

Rust library to ease the task of creating daemons

Matheus Xavier 38 Nov 25, 2022
Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

null 294 Dec 23, 2022
A runtime for writing reliable asynchronous applications with Rust. Provides I/O, networking, scheduling, timers, ...

Tokio A runtime for writing reliable, asynchronous, and slim applications with the Rust programming language. It is: Fast: Tokio's zero-cost abstracti

Tokio 18.7k Dec 30, 2022
delicate A lightweight and distributed task scheduling platform written in rust

A lightweight and distributed task scheduling platform written in rust.

BinCheng 529 Jan 9, 2023
Rust library for scheduling, managing resources, and running DAGs 🌙

?? moongraph ?? moongraph is a Rust library for scheduling, managing resources, and running directed acyclic graphs. In moongraph, graph nodes are nor

Schell Carl Scivally 3 May 1, 2023
a simple rust service for Scheduling commands execution on time basis, an easy alternative to cron

Tasker A Simple crate which provides a service and a configuration API for genrating commands based tasks ,on time basis. Installation build from sour

Daniel Madmon 5 Jun 1, 2023
Boids example ported from wgpu to rust-gpu

wgpu is Rust's main GPU project and rust-gpu is a project to write GPU shaders in Rust.

Thomas Buckley-Houston 2 Dec 1, 2022