@beanstalk/core
Advanced tools
Comparing version 0.2.2 to 0.3.0
@@ -7,4 +7,10 @@ /// <reference types="node" /> | ||
constructor(); | ||
connect(host?: string, port?: number): Promise<void>; | ||
/** | ||
* | ||
* @param host beanstalkd host (defaults to `localhost`) | ||
* @param port beanstalkd port (defaults to `11300`) | ||
* @param timeout connection timeout in milliseconds (defaults to `-1` = no timeout) | ||
*/ | ||
connect(host?: string, port?: number, timeout?: number): Promise<void>; | ||
/** | ||
* The quit command simply closes the connection. Its form is: | ||
@@ -11,0 +17,0 @@ * |
@@ -19,28 +19,39 @@ "use strict"; | ||
chunks.push(chunk); | ||
const emitter = this._pendingRequests[0]; | ||
if (emitter) { | ||
try { | ||
const buffer = Buffer.concat(chunks); | ||
const bRead = protocol_1.parse(buffer, messages); | ||
if (bRead > 0 && bRead === buffer.length) { | ||
for (const msg of messages) { | ||
emitter.emit('resolve', msg); | ||
} | ||
// clean-up | ||
chunks.length = 0; | ||
messages.length = 0; | ||
const buffer = Buffer.concat(chunks); | ||
const bRead = protocol_1.parse(buffer, messages); | ||
if (bRead > 0 && bRead === buffer.length) { | ||
for (const msg of messages) { | ||
const emitter = this._pendingRequests[0]; | ||
if (emitter) { | ||
emitter.emit('resolve', msg); | ||
this._pendingRequests.shift(); | ||
} | ||
else { | ||
console.error(`@beanstalk/core lost msg [code=${msg.code}]`); | ||
} | ||
} | ||
catch (err) { | ||
emitter.emit('reject', err); | ||
} | ||
// clean-up | ||
chunks.length = 0; | ||
messages.length = 0; | ||
} | ||
}); | ||
} | ||
async connect(host = 'localhost', port = 11300) { | ||
/** | ||
* | ||
* @param host beanstalkd host (defaults to `localhost`) | ||
* @param port beanstalkd port (defaults to `11300`) | ||
* @param timeout connection timeout in milliseconds (defaults to `-1` = no timeout) | ||
*/ | ||
async connect(host = 'localhost', port = 11300, timeout = -1) { | ||
return new Promise((resolve, reject) => { | ||
const errorHandler = (err) => reject(err); | ||
const timeoutHandler = () => this._socket.destroy(new Error('Connection timeout')); | ||
if (timeout > 0) { | ||
this._socket.setTimeout(timeout); | ||
this._socket.once('timeout', timeoutHandler); | ||
} | ||
this._socket.once('error', errorHandler); | ||
this._socket.connect(port, host, () => { | ||
// when connected: remove error/timeout handlers | ||
this._socket.off('timeout', timeoutHandler); | ||
this._socket.off('error', errorHandler); | ||
@@ -132,6 +143,12 @@ resolve(); | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.INSERTED) { | ||
return res.value; | ||
switch (res.code) { | ||
case protocol_1.M.INSERTED: | ||
return res.value; | ||
case protocol_1.M.BURIED: | ||
// XXX is this really considered an error? | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
throw new error_1.BeanstalkError(`Job '${res.value}' has been put in the buried queue`, res.code); | ||
default: | ||
throw new error_1.BeanstalkError('Unable to put a new job', res.code); | ||
} | ||
throw new error_1.BeanstalkError('Unable to put a new job', res.code); | ||
} | ||
@@ -159,3 +176,3 @@ /** | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.USING) { | ||
if (res.code === protocol_1.M.USING) { | ||
return res.value; | ||
@@ -188,3 +205,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.DELETED) { | ||
if (res.code === protocol_1.M.DELETED) { | ||
return; | ||
@@ -261,3 +278,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.RESERVED) { | ||
if (res.code === protocol_1.M.RESERVED) { | ||
return res.value; | ||
@@ -289,3 +306,3 @@ } | ||
// const cmd = Buffer.from(`reserve-job ${id}\r\n`); | ||
// const res = await this._send<Reserved>(cmd); | ||
// const res = await this._send(cmd); | ||
// if (res.code === S.RESERVED) { | ||
@@ -325,3 +342,3 @@ // return res.value; | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.RELEASED) { | ||
if (res.code === protocol_1.M.RELEASED) { | ||
return; | ||
@@ -353,3 +370,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.WATCHING) { | ||
if (res.code === protocol_1.M.WATCHING) { | ||
return res.value; | ||
@@ -379,3 +396,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.WATCHING) { | ||
if (res.code === protocol_1.M.WATCHING) { | ||
return res.value; | ||
@@ -413,3 +430,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.FOUND) { | ||
if (res.code === protocol_1.M.FOUND) { | ||
return res.value; | ||
@@ -446,3 +463,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.FOUND) { | ||
if (res.code === protocol_1.M.FOUND) { | ||
return res.value; | ||
@@ -479,3 +496,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.FOUND) { | ||
if (res.code === protocol_1.M.FOUND) { | ||
return res.value; | ||
@@ -512,3 +529,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.FOUND) { | ||
if (res.code === protocol_1.M.FOUND) { | ||
return res.value; | ||
@@ -539,3 +556,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.KICKED) { | ||
if (res.code === protocol_1.M.KICKED) { | ||
return res.value; | ||
@@ -567,3 +584,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.KICKED) { | ||
if (res.code === protocol_1.M.KICKED) { | ||
return; | ||
@@ -597,3 +614,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.OK) { | ||
if (res.code === protocol_1.M.OK) { | ||
return yaml_parser_1.yamlMap(res.value); | ||
@@ -627,3 +644,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.OK) { | ||
if (res.code === protocol_1.M.OK) { | ||
return yaml_parser_1.yamlMap(res.value); | ||
@@ -652,3 +669,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.OK) { | ||
if (res.code === protocol_1.M.OK) { | ||
return yaml_parser_1.yamlMap(res.value); | ||
@@ -676,3 +693,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.OK) { | ||
if (res.code === protocol_1.M.OK) { | ||
return yaml_parser_1.yamlList(res.value); | ||
@@ -701,3 +718,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.OK) { | ||
if (res.code === protocol_1.M.OK) { | ||
return yaml_parser_1.yamlList(res.value); | ||
@@ -723,3 +740,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.USING) { | ||
if (res.code === protocol_1.M.USING) { | ||
return res.value; | ||
@@ -750,3 +767,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.PAUSED) { | ||
if (res.code === protocol_1.M.PAUSED) { | ||
return; | ||
@@ -781,3 +798,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.S.TOUCHED) { | ||
if (res.code === protocol_1.M.TOUCHED) { | ||
return; | ||
@@ -812,3 +829,3 @@ } | ||
const res = await this._send(cmd); | ||
if (res.code === protocol_1.E.BURIED) { | ||
if (res.code === protocol_1.M.BURIED) { | ||
return; | ||
@@ -821,15 +838,10 @@ } | ||
const resultPromise = new Promise((resolve, reject) => { | ||
// const timeout = setTimeout(() => { | ||
// emitter.emit('timeout', new BeanstalkError(`Command '${cmd.slice(0, 10).toString()}' timed-out`, E.INTERNAL_ERROR)); | ||
// }, parseInt(process.env.TIMEOUT ?? '5') * 1000); | ||
emitter.on('resolve', resolve); | ||
emitter.on('reject', reject); | ||
// emitter.on('timeout', reject); | ||
emitter.once('resolve', resolve); | ||
emitter.once('reject', reject); | ||
}); | ||
this._pendingRequests.push(emitter); | ||
// FIXME consider adding a global timeout option to prevent infinite hanging on answers | ||
// or maybe we want to hang indefinitely? | ||
try { | ||
await new Promise((resolve, reject) => { | ||
this._socket.write(cmd, (err) => (err ? reject(err) : resolve())); | ||
}); | ||
await new Promise((r, e) => this._socket.write(cmd, (err) => (err ? e(err) : r()))); | ||
} | ||
@@ -836,0 +848,0 @@ catch (err) { |
@@ -1,5 +0,5 @@ | ||
import { E } from './protocol'; | ||
import { M } from './protocol'; | ||
export declare class BeanstalkError extends Error { | ||
readonly code: E; | ||
constructor(msg: string, code: E); | ||
readonly code: M; | ||
constructor(msg: string, code: M); | ||
} |
export * from './types'; | ||
export * from './client'; | ||
export * from './error'; | ||
export { S, E } from './protocol'; | ||
export { M } from './protocol'; |
@@ -13,3 +13,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.E = exports.S = void 0; | ||
exports.M = void 0; | ||
__exportStar(require("./types"), exports); | ||
@@ -19,4 +19,3 @@ __exportStar(require("./client"), exports); | ||
var protocol_1 = require("./protocol"); | ||
Object.defineProperty(exports, "S", { enumerable: true, get: function () { return protocol_1.S; } }); | ||
Object.defineProperty(exports, "E", { enumerable: true, get: function () { return protocol_1.E; } }); | ||
Object.defineProperty(exports, "M", { enumerable: true, get: function () { return protocol_1.M; } }); | ||
//# sourceMappingURL=index.js.map |
/// <reference types="node" /> | ||
import { S, E } from './protocol'; | ||
import { M } from './protocol'; | ||
export interface IPendingRequest { | ||
successCode: S; | ||
errorCodes: E[]; | ||
successCode: M; | ||
errorCodes: M[]; | ||
} | ||
@@ -7,0 +7,0 @@ export declare type ParseContext = { |
/// <reference types="node" /> | ||
import { Msg } from './types'; | ||
/** | ||
* Success codes | ||
* Messages | ||
*/ | ||
export declare enum S { | ||
export declare enum M { | ||
DELETED = "DELETED", | ||
INSERTED = "INSERTED", | ||
BURIED = "BURIED", | ||
RELEASED = "RELEASED", | ||
@@ -17,9 +18,3 @@ RESERVED = "RESERVED", | ||
PAUSED = "PAUSED", | ||
TOUCHED = "TOUCHED" | ||
} | ||
/** | ||
* Error codes | ||
*/ | ||
export declare enum E { | ||
BURIED = "BURIED", | ||
TOUCHED = "TOUCHED", | ||
DRAINING = "DRAINING", | ||
@@ -26,0 +21,0 @@ EXPECTED_CRLF = "EXPECTED_CRLF", |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parse = exports.E = exports.S = void 0; | ||
exports.parse = exports.M = void 0; | ||
const parse_utils_1 = require("./parse-utils"); | ||
/** | ||
* Success codes | ||
* Messages | ||
*/ | ||
// prettier-ignore | ||
var S; | ||
(function (S) { | ||
S["DELETED"] = "DELETED"; | ||
S["INSERTED"] = "INSERTED"; | ||
S["RELEASED"] = "RELEASED"; | ||
S["RESERVED"] = "RESERVED"; | ||
S["USING"] = "USING"; | ||
S["OK"] = "OK"; | ||
S["WATCHING"] = "WATCHING"; | ||
S["FOUND"] = "FOUND"; | ||
S["KICKED"] = "KICKED"; | ||
S["PAUSED"] = "PAUSED"; | ||
S["TOUCHED"] = "TOUCHED"; | ||
})(S = exports.S || (exports.S = {})); | ||
var M; | ||
(function (M) { | ||
M["DELETED"] = "DELETED"; | ||
M["INSERTED"] = "INSERTED"; | ||
M["BURIED"] = "BURIED"; | ||
M["RELEASED"] = "RELEASED"; | ||
M["RESERVED"] = "RESERVED"; | ||
M["USING"] = "USING"; | ||
M["OK"] = "OK"; | ||
M["WATCHING"] = "WATCHING"; | ||
M["FOUND"] = "FOUND"; | ||
M["KICKED"] = "KICKED"; | ||
M["PAUSED"] = "PAUSED"; | ||
M["TOUCHED"] = "TOUCHED"; | ||
M["DRAINING"] = "DRAINING"; | ||
M["EXPECTED_CRLF"] = "EXPECTED_CRLF"; | ||
M["JOB_TOO_BIG"] = "JOB_TOO_BIG"; | ||
M["NOT_FOUND"] = "NOT_FOUND"; | ||
M["DEADLINE_SOON"] = "DEADLINE_SOON"; | ||
M["TIMED_OUT"] = "TIMED_OUT"; | ||
M["NOT_IGNORED"] = "NOT_IGNORED"; | ||
M["BAD_FORMAT"] = "BAD_FORMAT"; | ||
M["OUT_OF_MEMORY"] = "OUT_OF_MEMORY"; | ||
M["INTERNAL_ERROR"] = "INTERNAL_ERROR"; | ||
M["UNKNOWN_COMMAND"] = "UNKNOWN_COMMAND"; | ||
})(M = exports.M || (exports.M = {})); | ||
/** | ||
* Error codes | ||
*/ | ||
// prettier-ignore | ||
var E; | ||
(function (E) { | ||
E["BURIED"] = "BURIED"; | ||
E["DRAINING"] = "DRAINING"; | ||
E["EXPECTED_CRLF"] = "EXPECTED_CRLF"; | ||
E["JOB_TOO_BIG"] = "JOB_TOO_BIG"; | ||
E["NOT_FOUND"] = "NOT_FOUND"; | ||
E["DEADLINE_SOON"] = "DEADLINE_SOON"; | ||
E["TIMED_OUT"] = "TIMED_OUT"; | ||
E["NOT_IGNORED"] = "NOT_IGNORED"; | ||
E["BAD_FORMAT"] = "BAD_FORMAT"; | ||
E["OUT_OF_MEMORY"] = "OUT_OF_MEMORY"; | ||
E["INTERNAL_ERROR"] = "INTERNAL_ERROR"; | ||
E["UNKNOWN_COMMAND"] = "UNKNOWN_COMMAND"; | ||
})(E = exports.E || (exports.E = {})); | ||
/** | ||
* @param buf a buffer containing Beanstalkd response messages | ||
@@ -55,70 +48,70 @@ * @param msgs fills this array with the parsed messages | ||
if (inserted(ctx, res)) { | ||
msgs.push({ code: S.INSERTED, value: res.value }); // casting to guard from future changes | ||
msgs.push({ code: M.INSERTED, value: res.value }); // casting to guard from future changes | ||
} | ||
else if (buried(ctx, res)) { | ||
msgs.push({ code: M.BURIED, value: res.value }); // casting to guard from future changes | ||
} | ||
else if (using(ctx, res)) { | ||
msgs.push({ code: S.USING, value: res.value }); // casting to guard from future changes | ||
msgs.push({ code: M.USING, value: res.value }); // casting to guard from future changes | ||
} | ||
else if (reserved(ctx, res)) { | ||
msgs.push({ code: S.RESERVED, value: res.value }); // casting to guard from future changes | ||
msgs.push({ code: M.RESERVED, value: res.value }); // casting to guard from future changes | ||
} | ||
else if (ok(ctx, res)) { | ||
msgs.push({ code: S.OK, value: res.value }); // casting to guard from future changes | ||
msgs.push({ code: M.OK, value: res.value }); // casting to guard from future changes | ||
} | ||
else if (watching(ctx, res)) { | ||
msgs.push({ code: S.WATCHING, value: res.value }); // casting to guard from future changes | ||
msgs.push({ code: M.WATCHING, value: res.value }); // casting to guard from future changes | ||
} | ||
else if (found(ctx, res)) { | ||
msgs.push({ code: S.FOUND, value: res.value }); // casting to guard from future changes | ||
msgs.push({ code: M.FOUND, value: res.value }); // casting to guard from future changes | ||
} | ||
else if (kicked(ctx, res)) { | ||
msgs.push({ code: S.KICKED, value: res.value }); // casting to guard from future changes | ||
msgs.push({ code: M.KICKED, value: res.value }); // casting to guard from future changes | ||
} | ||
else if (token(ctx, S.RELEASED, true)) { | ||
msgs.push({ code: S.RELEASED }); | ||
else if (token(ctx, M.RELEASED, true)) { | ||
msgs.push({ code: M.RELEASED }); | ||
} | ||
else if (token(ctx, E.BURIED, true)) { | ||
msgs.push({ code: E.BURIED }); | ||
else if (token(ctx, M.DRAINING, true)) { | ||
msgs.push({ code: M.DRAINING }); | ||
} | ||
else if (token(ctx, E.DRAINING, true)) { | ||
msgs.push({ code: E.DRAINING }); | ||
else if (token(ctx, M.EXPECTED_CRLF, true)) { | ||
msgs.push({ code: M.EXPECTED_CRLF }); | ||
} | ||
else if (token(ctx, E.EXPECTED_CRLF, true)) { | ||
msgs.push({ code: E.EXPECTED_CRLF }); | ||
else if (token(ctx, M.JOB_TOO_BIG, true)) { | ||
msgs.push({ code: M.JOB_TOO_BIG }); | ||
} | ||
else if (token(ctx, E.JOB_TOO_BIG, true)) { | ||
msgs.push({ code: E.JOB_TOO_BIG }); | ||
else if (token(ctx, M.DELETED, true)) { | ||
msgs.push({ code: M.DELETED }); | ||
} | ||
else if (token(ctx, S.DELETED, true)) { | ||
msgs.push({ code: S.DELETED }); | ||
else if (token(ctx, M.NOT_FOUND, true)) { | ||
msgs.push({ code: M.NOT_FOUND }); | ||
} | ||
else if (token(ctx, E.NOT_FOUND, true)) { | ||
msgs.push({ code: E.NOT_FOUND }); | ||
else if (token(ctx, M.DEADLINE_SOON, true)) { | ||
msgs.push({ code: M.DEADLINE_SOON }); | ||
} | ||
else if (token(ctx, E.DEADLINE_SOON, true)) { | ||
msgs.push({ code: E.DEADLINE_SOON }); | ||
else if (token(ctx, M.TIMED_OUT, true)) { | ||
msgs.push({ code: M.TIMED_OUT }); | ||
} | ||
else if (token(ctx, E.TIMED_OUT, true)) { | ||
msgs.push({ code: E.TIMED_OUT }); | ||
else if (token(ctx, M.NOT_IGNORED, true)) { | ||
msgs.push({ code: M.NOT_IGNORED }); | ||
} | ||
else if (token(ctx, E.NOT_IGNORED, true)) { | ||
msgs.push({ code: E.NOT_IGNORED }); | ||
else if (token(ctx, M.BAD_FORMAT, true)) { | ||
msgs.push({ code: M.BAD_FORMAT }); | ||
} | ||
else if (token(ctx, E.BAD_FORMAT, true)) { | ||
msgs.push({ code: E.BAD_FORMAT }); | ||
else if (token(ctx, M.UNKNOWN_COMMAND, true)) { | ||
msgs.push({ code: M.UNKNOWN_COMMAND }); | ||
} | ||
else if (token(ctx, E.UNKNOWN_COMMAND, true)) { | ||
msgs.push({ code: E.UNKNOWN_COMMAND }); | ||
else if (token(ctx, M.OUT_OF_MEMORY, true)) { | ||
msgs.push({ code: M.OUT_OF_MEMORY }); | ||
} | ||
else if (token(ctx, E.OUT_OF_MEMORY, true)) { | ||
msgs.push({ code: E.OUT_OF_MEMORY }); | ||
else if (token(ctx, M.INTERNAL_ERROR, true)) { | ||
msgs.push({ code: M.INTERNAL_ERROR }); | ||
} | ||
else if (token(ctx, E.INTERNAL_ERROR, true)) { | ||
msgs.push({ code: E.INTERNAL_ERROR }); | ||
else if (token(ctx, M.PAUSED, true)) { | ||
msgs.push({ code: M.PAUSED }); | ||
} | ||
else if (token(ctx, S.PAUSED, true)) { | ||
msgs.push({ code: S.PAUSED }); | ||
else if (token(ctx, M.TOUCHED, true)) { | ||
msgs.push({ code: M.TOUCHED }); | ||
} | ||
else if (token(ctx, S.TOUCHED, true)) { | ||
msgs.push({ code: S.TOUCHED }); | ||
} | ||
else { | ||
@@ -133,3 +126,3 @@ return ctx.offset; | ||
const start = ctx.offset; | ||
if (token(ctx, S.FOUND)) { | ||
if (token(ctx, M.FOUND)) { | ||
if (parse_utils_1.space(ctx)) { | ||
@@ -158,3 +151,3 @@ const id = {}; | ||
const start = ctx.offset; | ||
if (token(ctx, S.KICKED)) { | ||
if (token(ctx, M.KICKED)) { | ||
if (parse_utils_1.space(ctx)) { | ||
@@ -177,3 +170,3 @@ if (parse_utils_1.integer(ctx, res)) { | ||
const start = ctx.offset; | ||
if (token(ctx, S.OK)) { | ||
if (token(ctx, M.OK)) { | ||
if (parse_utils_1.space(ctx)) { | ||
@@ -198,3 +191,3 @@ const len = {}; | ||
const start = ctx.offset; | ||
if (token(ctx, S.INSERTED)) { | ||
if (token(ctx, M.INSERTED)) { | ||
if (parse_utils_1.space(ctx)) { | ||
@@ -211,5 +204,24 @@ if (parse_utils_1.integer(ctx, res)) { | ||
} | ||
function buried(ctx, res) { | ||
const start = ctx.offset; | ||
if (token(ctx, M.BURIED)) { | ||
if (parse_utils_1.space(ctx)) { | ||
if (parse_utils_1.integer(ctx, res)) { | ||
if (parse_utils_1.crlf(ctx)) { | ||
return true; | ||
} | ||
} | ||
} | ||
else { | ||
if (parse_utils_1.crlf(ctx)) { | ||
return true; | ||
} | ||
} | ||
} | ||
ctx.offset = start; | ||
return false; | ||
} | ||
function using(ctx, res) { | ||
const start = ctx.offset; | ||
if (token(ctx, S.USING)) { | ||
if (token(ctx, M.USING)) { | ||
if (parse_utils_1.space(ctx)) { | ||
@@ -229,3 +241,3 @@ if (parse_utils_1.string(ctx, 13, res)) { | ||
const start = ctx.offset; | ||
if (token(ctx, S.WATCHING)) { | ||
if (token(ctx, M.WATCHING)) { | ||
if (parse_utils_1.space(ctx)) { | ||
@@ -244,3 +256,3 @@ if (parse_utils_1.integer(ctx, res)) { | ||
const start = ctx.offset; | ||
if (token(ctx, S.RESERVED)) { | ||
if (token(ctx, M.RESERVED)) { | ||
if (parse_utils_1.space(ctx)) { | ||
@@ -247,0 +259,0 @@ const id = {}; |
/// <reference types="node" /> | ||
import { E, S } from './protocol'; | ||
import { M } from './protocol'; | ||
export declare type Scalar = string | number | boolean; | ||
@@ -20,63 +20,79 @@ export interface IPutOptions { | ||
} | ||
export declare type Msg = AnyError | Ok | Inserted | Deleted | Using | Reserved | Released | NotFound | Buried | ExpectedCrlf | JobTooBig | Draining | Watching | NotIgnored | Found | Kicked | Paused | Touched; | ||
export declare type AnyError = { | ||
code: E; | ||
export declare type Msg = BadFormat | Buried | DeadlineSoon | Deleted | Draining | ExpectedCrlf | Found | Inserted | InternalError | JobTooBig | Kicked | NotFound | NotIgnored | Ok | OutOfMemory | Paused | Released | Reserved | TimedOut | Touched | Using | Watching | UnknownCommand; | ||
export declare type BadFormat = { | ||
code: M.BAD_FORMAT; | ||
}; | ||
export declare type Deleted = { | ||
code: S.DELETED; | ||
export declare type Buried = { | ||
code: M.BURIED; | ||
value: number | undefined; | ||
}; | ||
export declare type Released = { | ||
code: S.RELEASED; | ||
export declare type DeadlineSoon = { | ||
code: M.DEADLINE_SOON; | ||
}; | ||
export declare type NotFound = { | ||
code: E.NOT_FOUND; | ||
export declare type Deleted = { | ||
code: M.DELETED; | ||
}; | ||
export declare type Buried = { | ||
code: E.BURIED; | ||
export declare type Draining = { | ||
code: M.DRAINING; | ||
}; | ||
export declare type ExpectedCrlf = { | ||
code: E.EXPECTED_CRLF; | ||
code: M.EXPECTED_CRLF; | ||
}; | ||
export declare type JobTooBig = { | ||
code: E.JOB_TOO_BIG; | ||
export declare type Found = { | ||
code: M.FOUND; | ||
value: [number, Buffer]; | ||
}; | ||
export declare type Draining = { | ||
code: E.DRAINING; | ||
export declare type Inserted = { | ||
code: M.INSERTED; | ||
value: number; | ||
}; | ||
export declare type NotIgnored = { | ||
code: E.NOT_IGNORED; | ||
export declare type InternalError = { | ||
code: M.INTERNAL_ERROR; | ||
}; | ||
export declare type Paused = { | ||
code: S.PAUSED; | ||
export declare type JobTooBig = { | ||
code: M.JOB_TOO_BIG; | ||
}; | ||
export declare type Touched = { | ||
code: S.TOUCHED; | ||
export declare type Kicked = { | ||
code: M.KICKED; | ||
value: number | undefined; | ||
}; | ||
export declare type Inserted = { | ||
code: S.INSERTED; | ||
value: number; | ||
export declare type NotFound = { | ||
code: M.NOT_FOUND; | ||
}; | ||
export declare type Using = { | ||
code: S.USING; | ||
value: string; | ||
export declare type NotIgnored = { | ||
code: M.NOT_IGNORED; | ||
}; | ||
export declare type Ok = { | ||
code: S.OK; | ||
code: M.OK; | ||
value: Buffer; | ||
}; | ||
export declare type OutOfMemory = { | ||
code: M.OUT_OF_MEMORY; | ||
}; | ||
export declare type Paused = { | ||
code: M.PAUSED; | ||
}; | ||
export declare type Released = { | ||
code: M.RELEASED; | ||
}; | ||
export declare type Reserved = { | ||
code: S.RESERVED; | ||
code: M.RESERVED; | ||
value: [number, Buffer]; | ||
}; | ||
export declare type Found = { | ||
code: S.FOUND; | ||
value: [number, Buffer]; | ||
export declare type TimedOut = { | ||
code: M.TIMED_OUT; | ||
}; | ||
export declare type Touched = { | ||
code: M.TOUCHED; | ||
}; | ||
export declare type UnknownCommand = { | ||
code: M.UNKNOWN_COMMAND; | ||
}; | ||
export declare type Using = { | ||
code: M.USING; | ||
value: string; | ||
}; | ||
export declare type Watching = { | ||
code: S.WATCHING; | ||
code: M.WATCHING; | ||
value: number; | ||
}; | ||
export declare type Kicked = { | ||
code: S.KICKED; | ||
value: number | undefined; | ||
}; |
{ | ||
"name": "@beanstalk/core", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"description": "Yet another Beanstalkd client library", | ||
@@ -15,3 +15,3 @@ "repository": "https://github.com/maxleiko/beanstalk-core", | ||
"compile": "tsc -b src", | ||
"doc": "typedoc --out docs --tsconfig src/tsconfig.json src", | ||
"doc": "typedoc --out docs --tsconfig src/tsconfig.json src && cp .jekyll-config.yml docs/.config.yml", | ||
"build": "yarn clean && yarn compile && yarn doc" | ||
@@ -18,0 +18,0 @@ }, |
@@ -66,9 +66,2 @@ ## @beanstalk/core | ||
}); | ||
``` | ||
### Available scripts: | ||
- `clean`: clean the generated bundle | ||
- `lint`: lints the `src` folder using `ESLint` | ||
- `test`: runs the test directly from TypeScript sources using `mocha` | ||
- `compile`: compiles the TypeScript `src` into `lib` | ||
- `build`: executes `test`, `clean` and `compile` | ||
``` |
78443
2172
66