dray-client
v0.0.15
Published
Node.js wrapper for managing Dray jobs
Downloads
758
Readme
Usage
Before creating jobs, you need to initialize the job manager:
import { DrayManager } from 'dray-client';
let manager = new DrayManager(
'http://0.0.0.0:3000', // Dray URL
'redis://127.0.0.1:6379' // Redis URL
);
Fire and forget
let job = manager.createJob();
job.addStep('foo/bar') // Container to be run
.submit(); // Fire and forget!
Wait for result
let job = manager.createJob();
job.setInput('foo') // Data passed to container
.addStep('centurylink/upper'); // Container to be run
// Fire and wait for promise
job.submit().then((value) => {
console.log("Result:", value);
}, (reason) => {
console.error("Something bad happened:", reason)
});
Start compilation job
import { BuildpackJob } from 'dray-client';
let compilation = new BuildpackJob(manager);
compilation.addFiles([
{name: 'foo.ino', data: new Buffer()}
]);
compilation.setEnvironment({
PLATFORM_ID: 6
});
compilation.setBuildpacks([
'particle/buildpack-wiring-preprocessor',
'particle/buildpack-particle-firmware:0.5.1-photon'
]);
compilation.submit().then((binaries) => {
// Do something with binaries
}, (reason) => {
console.error("Compilation error:", reason)
});
API Reference
Development
Releasing
- Prebuid
dist
directory usingnpm build
- Bump version with
npm version <major|minor|patch>
- Push the repo
- Publish on npm:
npm publish