Code Monkey home page Code Monkey logo

oppgave's Introduction

oppgave - A simple Redis-based task queue

crates.io Build Status

Inspired by Ost and Kute.

A small reliable queue on top of Redis. Allows to push tasks and fetch them again. Can handle whatever task object you hand it, as long as it can be encoded and decoded to and from JSON.

The name: oppgave - task

oppgave is Norwegian for task. So oppgave is a oppgave kø, a task queue.

Sadly, characters like ø don't play to well with stable Rust. Non-ASCII identifiers are feature-gated.

It would be possible with nightly and the non_ascii_idents feature to use oppgave-kø, but crates.io doesn't accept crates with non-ascii characters in the name. :(

Documentation is available online.

Installation

Add it to your dependencies in Cargo.toml

[dependencies]
oppgave = "0.1.0"

Example: Producer

See examples/worker.rs for a working example. Run it with cargo run --example worker.

#[derive(RustcDecodable, RustcEncodable)]
struct Job { id: u64 }

let client = redis::Client::open("redis://127.0.0.1/").unwrap();
let con = client.get_connection().unwrap();
let producer = Queue::new("default".into(), con);

producer.push(Job{ id: 42 });

Example: Worker

See examples/worker.rs for a working example. Run it with cargo run --example worker.

#[derive(RustcDecodable, RustcEncodable)]
struct Job { id: u64 }

let client = redis::Client::open("redis://127.0.0.1/").unwrap();
let con = client.get_connection().unwrap();
let worker = Queue::new("default".into(), con);

while let Some(task) = worker.next() {
    println!("Working with Job {}", job.id);
}

License

MIT. See LICENSE.

oppgave's People

Contributors

badboy avatar mati865 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.