Git Product home page Git Product logo

taskermq's Introduction

TaskerMQ

TaskerMQ is a Redis based simple background job processor for Deno ๐Ÿฆ•.

Usage

// sampleWorker.ts
import { WorkerClass } from 'https://deno.land/x/taskermq/mod.ts';

export default class SampleWorker extends WorkerClass {
  // this is the function you need to perform the background job
  perform(params) {
    console.log(params[0] + params[1])
  }
}
// work.ts
import { Connection, Tasker } from "https://deno.land/x/taskermq/mod.ts";
import SampleWorker from "./samplerWorker.ts";

// Configure your connection to the redis instance
const connection = new Connection({
  hostname: "localhost",
  port: 6379,
});

// Accept a new queue name for your task
const queue = Deno.args[0] || "taskerMQdefault";

// Connect to the redis instance
await connection.connectRedis();

// Create a new Tasker instance using the redis connection, queue name and an array of worker classes
const tasker = new Tasker(connection, queue, [SampleWorker]);

// Run tasker as a long running process.
tasker.run();

Our job processor is now set-up. Now we have to start adding jobs to the queue. TaskerMQ assumes the jobs to be in serialized JSON with the following format:

{"klass": "SampleWorker", "params": [1, 2]}

TaskerMQ will try to deserialize the string and execute the job.

NOTE: Any job not in the correct format will be ignored and removed from the queue.

To run the worker:

deno run --allow-net work.ts sample-worker-queue

taskermq's People

Contributors

ronyv89 avatar

Stargazers

Alec Brunelle avatar Wout 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.