Git Product home page Git Product logo

app-queue's Introduction

App-Queue

App-queue is a simple persistent in-app queue for Rust. It is designed to be dropped into monolithic applications, and provide automatic queueing and retrying for asynchronous tasks.

Additionally, it allows the use of any serializable data type for requests.

By default, if a job returns an error, it will be retried indefinitely with exponential backoff (600s max delay). This can however be overridden on a per-job-type basis.

Sample usage, from the documentation:

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct MyJob {
    message: String
}

#[typetag::serde]
#[async_trait::async_trait]
impl Job for MyJob {
  async fn run(&mut self, _: Arc<AppQueue>) -> Result<()> {
    println!("{}", self.message);
    Ok(())
  }
}

#[tokio::main]
async fn main() -> Result<()> {
# tracing_subscriber::fmt::init();
  let queue = AppQueue::new("/tmp/queue.db").await?;
  let job = MyJob {
    message: "Hello, world!".into()
  };
  queue.add_job(Box::new(job)).await?;
  queue.run_job_workers_default();
  Ok(())
}

A larger example can be found here.

Caveats

Incompatible schema changes (Renaming/Removal of Job structs), as well as incompatible changes in the structure of the job itself will cause jobs to get stuck in the queue. This will cause errors to show up on startup, however they will be ignored for the rest of the program’s runtime.

Limitations

Potentially desirable features that are currently not supported:

  • Integration with the app’s storage. The app likely already uses a database, and it would be useful to only have one database total. Proper DBMSes may also improve performance in some cases.

app-queue's People

Contributors

darkkirb avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.