JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 17989
  • Score
    100M100P100Q142021F
  • License MIT

celery written in nodejs

Package Exports

  • celery-node

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (celery-node) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

celery.node

Nodejs client/server for celery
This project focuses on using celery protocol in nodejs influenced by node-celery

Install

$ npm install celery-node

Example

Client

celery.node

client.js

const celery = require('celery-node');

const client = celery.createClient({
  CELERY_BROKER: 'amqp://',
  CELERY_BACKEND: 'amqp://'
});
const result = client.delay('tasks.add', [1, 2]);
setTimeout(() => {
  result.get()
    .then(data => {
      console.log(data);
    });
}, 1000);

python

from celery import Celery

app = Celery('tasks',
    broker='amqp://',
    backend='amqp://'
)

app.conf.update(
    CELERY_TASK_PROTOCOL=1,
)

@app.task
def add(x, y):
    return x + y

if __name__ == '__main__':
    result = add.apply_async((1, 2), serializer='json')
    print(result.get())

Worker

celery.node

worker.js

const celery = require('..');

const worker = celery.createWorker({
  CELERY_BROKER: 'amqp://',
  CELERY_BACKEND: 'amqp://'
});
worker.register('tasks.add', (a, b) => a + b);
worker.start();

python

from celery import Celery

app = Celery('tasks',
    broker='amqp://',
    backend='amqp://'
)

app.conf.update(
    CELERY_TASK_PROTOCOL=1,
)

@app.task
def add(x, y):
    return x + y
$ celery worker -A tasks --loglevel=INFO

License

  • MIT