All Projects → davesag → amqp-delegate

davesag / amqp-delegate

Licence: MIT License
A simple, but performant, remote worker system that uses AMQP to coordinate jobs.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to amqp-delegate

celery.node
Celery task queue client/worker for nodejs
Stars: ✭ 164 (+645.45%)
Mutual labels:  worker, amqp
azure-service-bus-dotnet-plugins
☁️ Plugins for the .NET Standard client library for Azure Service Bus
Stars: ✭ 15 (-31.82%)
Mutual labels:  amqp
bee-apm
BeeAPM is a distributed tracing system and APM ( Application Performance Monitoring )
Stars: ✭ 137 (+522.73%)
Mutual labels:  agent
hpagent
A ready to use http and https agent for working with proxies that keeps connections alive!
Stars: ✭ 86 (+290.91%)
Mutual labels:  agent
nomad-plugin
Nomad cloud plugin for Jenkins
Stars: ✭ 53 (+140.91%)
Mutual labels:  agent
eXperDB-Management
eXperDB-Management is a integrated management tool for PostgreSQL(for efficient operation and management).
Stars: ✭ 38 (+72.73%)
Mutual labels:  agent
agent
Store sensitive data such as API tokens
Stars: ✭ 19 (-13.64%)
Mutual labels:  agent
spring-boot-rabbitMQ
Spring Boot集成rabbitMQ实现消息推送
Stars: ✭ 24 (+9.09%)
Mutual labels:  amqp
qpid-proton-j
Mirror of Apache Qpid Proton-J
Stars: ✭ 28 (+27.27%)
Mutual labels:  amqp
mom
Proof of concept for Message-Oriented-Middleware based architecture.
Stars: ✭ 39 (+77.27%)
Mutual labels:  amqp
AgentBaker
Agent Baker is aiming to provide a centralized, portable k8s agent node provisioning lib as well as rich support on different OS image with optimized k8s binaries.
Stars: ✭ 45 (+104.55%)
Mutual labels:  agent
qpid-dispatch
Mirror of Apache Qpid Dispatch
Stars: ✭ 62 (+181.82%)
Mutual labels:  amqp
msw-storybook-addon
Mock API requests in Storybook with Mock Service Worker.
Stars: ✭ 168 (+663.64%)
Mutual labels:  worker
javametrics
Application Metrics for Java™ instruments the Java runtime for performance monitoring, providing the monitoring data visually with its built in dashboard
Stars: ✭ 19 (-13.64%)
Mutual labels:  agent
workit
Extensible worker for Node.js that works with both Zeebe and Camunda BPM platforms powered by TypeScript
Stars: ✭ 51 (+131.82%)
Mutual labels:  worker
node-amqp
Module for easy amqp comunication
Stars: ✭ 22 (+0%)
Mutual labels:  amqp
simple-proxy-agent
Simple agent for sending HTTP and HTTPS traffic through HTTP and SOCKS proxies
Stars: ✭ 20 (-9.09%)
Mutual labels:  agent
OneAgent-SDK
Describes technical concepts of Dynatrace OneAgent SDK
Stars: ✭ 15 (-31.82%)
Mutual labels:  agent
relearn
A Reinforcement Learning Library for C++11/14
Stars: ✭ 22 (+0%)
Mutual labels:  agent
wolfpacs
WolfPACS is an DICOM load balancer written in Erlang.
Stars: ✭ 1 (-95.45%)
Mutual labels:  worker

amqp-delegate

A remote worker system that uses AMQP to coordinate jobs.

NPM

See Also

  • amqp-simple-pub-sub — A library that simplifies use of AMQP based publishers and subscribers.

Usage

npm install amqp-delegate

Worker

const { makeWorker } = require('amqp-delegate')

const worker = makeWorker({
  url: 'ampq://localhost:5672', // the default
  name: 'the name of the worker', // required
  task: async () => 'any pure async function', // required
  onError: err => { // optional
    console.error('A connection error happened', err) // or do something clever
  }
  onClose: () => { // optional
    console.log('The connection has closed.') // or do something clever
  }
})

// start it
worker.start().then(() => {
  console.log('worker', worker.name, 'started')
})

// stop it
worker.stop().then(() => {
  console.log('worker', worker.name, 'stopped')
})

Delegator

const { makeDelegator } = require('amqp-delegate')

const delegator = makeWorker({
  url: 'ampq://localhost:5672', // the default
  onError: err => { // optional
    console.error('A connection error happened', err) // or something clever
  }
  onClose: () => { // optional
    console.log('The connection has closed.') // or something clever
  }
})

delegator
  .start()
  .then(() => {
    delegator.invoke('worker name', ...params)
    console.log('job name', result)
  })
  .catch(err => {
    console.error('worker name', err)
  })

A concrete example

The worker

const { makeWorker } = require('amqp-delegate')

const task = (a, b) => new Promise(resolve => setTimeout(() => resolve(a + b), 10))

const worker = makeWorker({
  name: 'adder',
  task
})

worker
  .start()
  .then(() => {
    process.on('SIGINT', () => {
      worker.stop().then(() => {
        process.exit(0)
      })
    })
  })
  .catch(err => {
    console.error('caught', err)
  })

The delegator

const { makeDelegator } = require('amqp-delegate')

const delegator = makeDelegator()

delegator
  .start()
  .then(() => delegator.invoke('adder', 10, 15))
  .then(result => {
    console.log('result', result)
  })
  .catch(err => {
    console.error('caught', err)
  })

Development

Branches

branch status coverage Audit notes
develop CircleCI codecov Vulnerabilities Work in progress
main CircleCI codecov Vulnerabilities Latest stable release

Prerequisites

  • NodeJS, 10.0+ (I use nvm to manage Node versions — brew install nvm.)
  • Docker (Use Docker for Mac, not the homebrew version)

Initialisation

npm install

To Start the queue server for integration testing.

docker-compose up -d

Runs Rabbit MQ.

Test it

  • npm test — runs the unit tests (does not need rabbitmq)
  • npm run test:unit:cov — runs the unit tests with code coverage (does not need rabbitmq)
  • npm run test:integration — runs the integration tests (needs rabbitmq)

Lint it

npm run lint

Contributing

Please see the contributing notes.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].