Giter Site home page Giter Site logo

fusion-queue's Introduction

@sphinx-software/queue

A queue for sphinx-fusion

  • support rabitmq using amqp
  • support sqs using aws-sdk
  • support redis-queue using rsmq
  • support database-queue using knex for Postgres, MSSQL, MySQL, MariaDB, SQLite3, and Oracle
  • support null-queue,memory-queue

implements Job

class Job {

    constructor(name) {
        this.name = name;
    }
    
    get flow() {
        // overwrite option flow default (no required)
        return {
            delay:1000,
            timeout:15000,
            retry:3,
            pushBack:true,
        }
    }

    handle() {
        // run task 
        console.log(`hello ${this.name}`);
    }
}

Provider Register

let serializer = await container.make('serializer');
serializer.forType(Job,
    (job) => job.name,
    (jobData) => new Job(jobData.name)
)

Controller

contructor(queueManager) {
    this.queueManager = queueManager;
}
static get dependencies() {
    return ['queueManager'];
}

use() {
    this.queueManager.to('myQueue').enqueue(new Job('word'));
}

Config options queue

queue {
    default: 'databaseQueue',
    queues : {
        rabbitMQ     : {
            url        : 'amqp://localhost',
            adapter    : 'amqp',
            channelName: 'someName',
            // flow default for queue if flow for job is not available            
            flow       : 'timeout:15000|delay:0|retry:3|rotateBack',
            // For more options see http://www.squaremobius.net/amqp.node/channel_api.html#channel_get
            options    : {
                send   : {
                    noAck: true
                },
                receive: {
                    noAck: true
                }
            }
        },
        redisMQ      : {
            host       : '127.0.0.1',
            flow       : 'timeout:15000|delay:900000|retry:3|pushBack',
            port       : 6379,
            adapter    : 'rsmq',
            channelName: 'someName2'
        },
        SQS          : {
            flow           : 'timeout:15000|delay:30000|retry:3|rotateBack',
            adapter        : 'sqs',
            queueUrl       : 'queueURL',
            accessKeyId    : 'accessKeyId',
            secretAccessKey: 'secretAccessKey',
            region         : 'us-east-1'
        },
        databaseQueue: {
            flow   : 'timeout:15000|delay:30000|retry:3|rotateBack',
            adapter: 'database'
        }
    }
};

Licences

MIT

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.