later
A distributed background job manager and runner for Rust. This is currently in PoC stage.
How to enqueue Fire and Forget jobs
1. Import later and required dependencies
= "0.0.3"
= "1.0"
2. Define some types to use as a payload to the background jobs
use ;
// <- Required derives
// ... more as required
3. Generate the stub
background_job!
This generates two types
JobsBuilder- used to bootstrap the background job server - which can be used to enqueue jobs,JobContext<T>- used to pass application context (T) in the handler as well as enqueue jobs,
4. Use the generated code to bootstrap the background job server
For struct Jobs a type JobsBuilder will be generated. Use this to bootstrap the server.
// bootstrap the server
let job_ctx = JobContext ;
let ctx = MyContext; // Any context to pass onto the handlers
let storage = new // More storage option to be available later
.await
.expect;
let bg_jobs = new
// for each payload defined in the `struct Jobs` above
// the generated fn name uses the pattern "with_[name]_handler"
.with_send_email_handler // Pass the handler function
// ..
.build
.expect;
// use bg_jobs.enqueue(SendEmail{ ... }) to enqueue jobs,
// or bg_jobs.enqueue_continue(parent_job_id, SendEmail{ ... }) to chain jobs.
// this will only accept types defined inside the macro above
// define handler
Project status
This is PoC at this moment. I aim to make something like Hangfire for .NET. Upcoming features are
- Multiple storage backend (redis, postgres)
- Continuation
- Delayed Jobs (WIP)
- Recurring jobs
- Dashboard
- Use storage backend for scheduling (to remove dependency to RabbitMQ)