0.6.1 • Published 6 years ago

faktory-client v0.6.1

Weekly downloads
1
License
GPL-3.0
Repository
github
Last release
6 years ago

faktory-client

Travis branch Coveralls github branch David node

A node.js client for the Faktory job server

This repository provides a node.js client for Faktory. The client allows you to push jobs, fetch jobs, and otherwise communicate with the Faktory server.

If you're looking for a faktory worker framework for node.js, take a look at jbielick/faktory_worker_node. This is just the connection client library.

Installation

npm install faktory-client

Usage

faktory-client implements a promise interface for all async methods.

Pushing jobs

const client = require('faktory-client').create();

await client.connect();
await client.push({
  jobtype: 'MyJobName',
  queue: 'critical', // `default` if omitted
  args: [1]
});

Fetching jobs

const client = require('faktory-client').create({ labels: ['hungry'] });

await client.connect();
// fetches from each queue in order, blocking for 2s on each if they are empty
const job = await client.fetch('default', 'critical', 'low');

job.jid
// 8ec88fc8-5060-451c-8ebb-efd4cb9c4a97

await client.ack(job.jid);
// or
await client.fail(job.jid, new Error('guess again!'));

See tests for more examples.

FAQ

  • How do I specify the Faktory server location?

By default, it will use tcp://localhost:7419 which is sufficient for local development. Use FAKTORY_URL to specify the URL, e.g. tcp://faktory.example.com:12345 or use FAKTORY_PROVIDER to specify the environment variable which does contain the URL: FAKTORY_PROVIDER=FAKTORYTOGO_URL. This level of indirection is useful for SaaSes, Heroku Addons, etc.

See the Faktory client for other languages

TODO

  • Heartbeats
  • Reconnects
  • Connection interrupt graceful shutdown
  • Quiet/Stop signal handling from server
  • TLS

Development

Install docker.

bin/server will run the faktory server in a docker container. The server is available at localhost:7419

Use DEBUG=faktory* to see debug lines.

Tests

Start a faktory server on localhost or use bin/server.

npm test will run the tests concurrently with ava.

Author

Josh Bielick, @jbielick

0.6.1

6 years ago

0.6.0

6 years ago

0.5.0

6 years ago

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago