taskfire
NodeJS Client for Taskfire
Last updated 2 years ago by calum.moore .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install taskfire 
SYNC missed versions from official npm registry.

Taskfire Node.js Library

Build Status Coverage Status

Official NodeJS client for Taskfire. The library provides convenient access to the Taskfires API from applications written in server-side JavaScript (Node JS).

Please only use this with server-side Node as it uses your Taskfire project secret token (which should never be publicly revealed).

Install with:

npm install taskfire

Usage

The package needs to be configured with your project's secret token which is available in your project settings. You must instantiate a new client for each project you want to connect to.

Push a job into example-queue-id:

const client = require('taskfire')('<secret_token>')
// OR import taskfire from 'taskfire'
// const client = taskfire(('<secret_token>')

const job = client.queues
  .push('example-queue-id', {
    data: { x: ????, y: 2 },
    retries: 3,
  })
  .progress((progress, job) => {
    // Things are moving along! ⏳
  })
  .then((job) => {
    // Work has been completed! ????
  })

Create a worker for example-queue-id:

const client = require('taskfire')('<secret_token>')

client.queues
  .process('super-fly-queue', options, async (job, done) => {
    // Work on the queue and report progress
    job.progress(20)

    // Return a promise or call done,
    // when you're finished
    return ????
  })

API

The API allows either Promise or callbacks to be used.

taskfire (secretAuthToken, options)

Helper function, returns a new instance of TaskfireClient.

TaskfireClient (secretAuthToken, options)

Creates a new instance of the Taskfire client class.

options object properties

Property Default Description
url [wss://api.taskfire.io] The Taskfire API URL.
debug false Add additional console logs

queues.create (queue, cb) => Promise<Queue>

Creates a new queue.

queue: Object - properties for the new queue

  • [id] - ID of the queue
  • [name] - Name of the queue

[cb]: Function - callback which resolves with Queue

Queue

Queue instances are returned by the client, and represent one queue. They have convenience methods on them to make changes to the queue.

Task

Task instances are returned by the client, and represent one task. They have convenience methods on them to make changes to the task.

Running Tests

Run (at project root): yarn test

Current Tags

  • 0.2.0                                ...           latest (2 years ago)

8 Versions

  • 0.2.0                                ...           2 years ago
  • 0.1.8                                ...           2 years ago
  • 0.1.7                                ...           2 years ago
  • 0.1.6                                ...           2 years ago
  • 0.1.5                                ...           2 years ago
  • 0.1.4                                ...           2 years ago
  • 0.1.3                                ...           2 years ago
  • 0.1.2                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 1
Last Month 0
Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |