CronFrame 0.1.3
CronFrame is both a framework and a CLI tool.
The framework allows for the definition and scheduling of cron jobs with macros both on functions in the "global scope" and inside struct types to be used inside Rust projects.
Job creation without macros is possible, refer to the example in no_macros.rs
on the repo.
The CLI tool of the same name is used to spin a global instance of the framework read to accept job that can be added either from cli comands.
Getting Started
To use the framework in your Rust project:
The linkme crate is required for macros to work, more recent versions of linkme might also work.
To install the CLI tool:
General Information
The cron expression parser used is cron.
Scheduling time is in UTC.
There are three types of jobs that can be defined:
- global jobs
- function jobs
- method jobs
Each of these is defined with a macro, a standalone macro for global jobs while function a method jobs require a little bit of setup.
A struct that can host jobs is known as a cron object
in the context of cronframe and is defined with the cron_obj
macro.
Jobs of a cron object must be defined inside a standalone implementation block annotated with the macro cron_impl
.
NOTICE: a cron object derives the Clone trait so its fields must too.
The framework supports a daily timeout (timed-out state resets every 24hrs) in ms which is decativated if the value is 0.
During the first run of the framework a templates folder will be created in the current directory with 7 files inside it:
- base.html.tera
- index.htm.tera
- job.html.tera
- tingle.js
- cronframe.js
- styles.css
- tingle.css
By default the server runs on localhost:8098, the port can be changed in the cronframe.toml
file.
More configuration options available via cronframe.toml
.
The default size of a log file is 1MB.
If you use the CLI tool, the templates directory, the log directory and any other file related to cronframe will be in the .cronframe directory under the user directory.
Tutorial
For the tutorial refer to the website.
Defining A Global Job
extern crate cronframe;
use CronFrame;
Defining A Function Job
extern crate cronframe;
use CronFrame;
Defining A Method Job
extern crate cronframe;
use ;
The CLI Tool
Upon first start the tool generates a .cronframe directory inside the user's home directory.
This directory contains the templates folder, the log folder, the cargo_targets folder and the cli_jobs folder.
To configure the cronframe instance of the CLI tool with the cronframe.toml file, put it in the .cronframe directory.
Running Examples
If the example is in a single file like base_example.rs
use the following command:
If the example is in its own crate like weather_alert
do the following:
Running Tests
Tests must be run sequentially and not in parallel since they rely on the logger output.