tasks-sdk
Coming soon (:tm:)...
Last updated 4 months ago by pedrocarrico .
ISC · Original npm · Tarball · package.json
$ cnpm install tasks-sdk 
SYNC missed versions from official npm registry.

Tasks SDK

CircleCI

Installing / Getting started

npm install @streethub/tasks-sdk@<version> --save

This installs the tasks-sdk package into your project, in order to use it in your code do:

const tasks = require('@streethub/tasks-sdk');

tasks.create('create pdf', 'http://service.example.com', 'This is the task payload');

Developing

In order to start developing:

git clone git@github.com:Trouva/tasks-sdk.git
cd tasks-sdk/
npm install
npm test
npm run eslint
npm run coverage

This will clone this repo, install the dependencies, run the tests, eslint and coverage reports.

You can find the coverage report under coverage/index.html after running the coverage task.

Deploying / Publishing

Publishing new version to npm is handled by the CircleCI build, just point to the workflow you want to publish and manually chose the kind of version (major, minor or patch) you want to publish for this library.

Features

Create task

Creates a remote task for further processing on the tasks-service:

tasks.create(taskName, endpoint, payload);

payload can be passed as a string or an object but keep in mind that it will be JSON.stringified upon sending the request to the tasks service.

Complete task

Marks the task as completed:

tasks.complete(taskId, message);

message is optional and you can pass a string or an object to be JSON.stringified upong sending the request to tasks service.

Fail task

Sets the task status to failed:

tasks.fail(taskId, error);

error is optional and you can pass a string or an object to be JSON.stringified upong sending the request to tasks service.

Get task

Gets a task by id:

tasks.get(taskId);

Get tasks

Gets all tasks for this service:

tasks.all(numberOfResults, offset)

Start task

Notifies the task service that the task is running:

tasks.start(taskId);

Promise support

All the methods return a Promise, if need you can also override the default Javasript promise implementation and set your own like this:

const Bluebird = require('bluebird');

tasks.promiseImplementation(Bluebird);

Timeout support

All the methods have an optional parameter for a timeout in milliseconds that will timeout the request:

tasks.complete(taskId, message, timeoutInMs);

Environment Variables

Most options can be configured through these environment variables:

Environment Variable Description Default
APP_NAME Sent as the user agent in the request N/A
TASK_SERVICE_URL The tasks service base URL ''
TASK_SERVICE_TOKEN The token to use for autentication undefined

Current Tags

  • 0.0.1-alpha                                ...           latest (4 months ago)

2 Versions

  • 0.0.1-beta                                ...           4 months ago
  • 0.0.1-alpha                                ...           4 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (2)
Dev Dependencies (18)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |