boaty-mcboatface-client
v2.0.0
Published
Boaty McBoat Face node client
Downloads
6
Readme
boaty-client
A node client for the boaty mcboatface job server
Installation
npm install --save boaty-mcboatface-client
Usage
To creating a new or assume an existing queue with one operation:
const Client = require("boaty-mcboatface-client");
const GUID = Math.round(Math.random() * 9999999)).toString(16);
// NOTE: The Boaty client assumes a trailing slash.
const boaty = new Client(GUID, "first,second,third", "http://URL_TO_BOATY_SERVER:port/");
const nextItem = boaty.pop();
Checking if a queue with a given guid
exists and whether work remains to be done:
const Client = require("boaty-mcboatface-client");
const GUID = "ABC123";
// NOTE: The Boaty client assumes a trailing slash.
// NOTE: The Boaty client throws an error if the server returns a garbled or non-404 error result.
const queue = Client.getQueue("http://URL_TO_BOATY_SERVER:port/", GUID);
if (queue) {
if (queue.length > 0) {
// The queue exists and still has work to claim
console.log(`Queue with id ${GUID} exists and is not yet empty.`);
} else {
// This queue may have already had all its work claimed
console.log(`Queue with id ${GUID} exists, and has no remaining items left.`);
}
} else {
// No queue with this guid has been created recently
console.log(`Queue with id ${GUID} does not yet exist. OK to initialize a queue with this id.`);
}
License
All code not otherwise specified is Copyright Wal-Mart Stores, Inc. Released under the MIT License.