@taskbotjs/client
Advanced tools
Comparing version 0.1.0-alpha.5 to 0.9.0
@@ -8,3 +8,3 @@ import Bunyan from "bunyan"; | ||
import { IQueue } from "../ClientBase/IQueue"; | ||
import { RetryJobSortedSet, ScheduledJobSortedSet, DeadJobSortedSet, DoneJobSortedSet } from "./JobSortedSets"; | ||
import { RetryJobSortedSet, ScheduledJobSortedSet, DeadJobSortedSet } from "./JobSortedSets"; | ||
import { ICounter } from "../ClientBase/ICounter"; | ||
@@ -14,3 +14,2 @@ import { WorkerInfo, MetricDayRange, QueueInfo, StorageInfo } from ".."; | ||
import { Multi } from "redis"; | ||
import { IDone } from "../ClientBase/ISortedSet"; | ||
import { ClientMiddleware } from "../ClientMiddleware"; | ||
@@ -22,3 +21,2 @@ export declare class Client extends ClientBase<AsyncRedis> { | ||
readonly deadSet: DeadJobSortedSet; | ||
readonly doneSet: DoneJobSortedSet; | ||
private readonly queues; | ||
@@ -44,3 +42,2 @@ constructor(logger: Bunyan, asyncRedis: AsyncRedis, middleware?: ClientMiddleware); | ||
withDeadSet<T>(fn: (dead: IDead) => Promise<T>): Promise<T>; | ||
withDoneSet<T>(fn: (done: IDone) => Promise<T>): Promise<T>; | ||
getQueueInfo(): Promise<Array<QueueInfo>>; | ||
@@ -47,0 +44,0 @@ getWorkerInfo(): Promise<Array<WorkerInfo>>; |
@@ -32,3 +32,2 @@ "use strict"; | ||
this.deadSet = new JobSortedSets_1.DeadJobSortedSet(this.logger, this, this.asyncRedis); | ||
this.doneSet = new JobSortedSets_1.DoneJobSortedSet(this.logger, this, this.asyncRedis); | ||
} | ||
@@ -102,3 +101,3 @@ queue(queueName) { | ||
this.logger.trace({ jobIds }, "Fetching jobs."); | ||
const jsons = await this.asyncRedis.mget(...keys); | ||
const jsons = jobIds.length > 0 ? await this.asyncRedis.mget(...keys) : []; | ||
return Promise.all(jsons.map(async (json) => { | ||
@@ -124,3 +123,3 @@ if (json) { | ||
this.logger.trace({ jobId: id }, "Deleting job."); | ||
const num = await this.asyncRedis.del(id); | ||
const num = await this.asyncRedis.del(`jobs/${id}`); | ||
if (num !== 1) { | ||
@@ -142,5 +141,2 @@ this.logger.info({ jobId: id }, "DEL returned non-1 value; potential anomaly."); | ||
} | ||
async withDoneSet(fn) { | ||
return fn(this.doneSet); | ||
} | ||
async getQueueInfo() { | ||
@@ -147,0 +143,0 @@ const keys = await this.scanAll("queue/*"); |
@@ -5,3 +5,3 @@ import Bunyan from "bunyan"; | ||
import { JobDescriptor, JobDescriptorOrId } from "../JobMetadata"; | ||
import { IRetries, IScheduled, IDead, IDone, IJobSortedSet } from "../ClientBase/ISortedSet"; | ||
import { IRetries, IScheduled, IDead, IJobSortedSet } from "../ClientBase/ISortedSet"; | ||
import { ScoreSortedSet } from "./ScoreSortedSet"; | ||
@@ -26,4 +26,1 @@ import { Client } from "."; | ||
} | ||
export declare class DoneJobSortedSet extends JobSortedSet implements IDone { | ||
constructor(baseLogger: Bunyan, client: Client, asyncRedis: AsyncRedis); | ||
} |
@@ -114,7 +114,1 @@ "use strict"; | ||
exports.DeadJobSortedSet = DeadJobSortedSet; | ||
class DoneJobSortedSet extends JobSortedSet { | ||
constructor(baseLogger, client, asyncRedis) { | ||
super(baseLogger, client, asyncRedis, "done", client.redisPrefix, doneScorer); | ||
} | ||
} | ||
exports.DoneJobSortedSet = DoneJobSortedSet; |
@@ -10,3 +10,3 @@ import Bunyan from "bunyan"; | ||
import { QueueInfo, StorageInfo, BasicMetrics, WorkerInfo, MetricDayRange, DurationFields } from "../domain"; | ||
import { IRetries, IDead, IScheduled, IDone } from "./ISortedSet"; | ||
import { IRetries, IDead, IScheduled } from "./ISortedSet"; | ||
export { IRetries, IDead, IScheduled } from "./ISortedSet"; | ||
@@ -30,3 +30,2 @@ export declare type DateLike = Date | DateTime | { | ||
abstract readonly deadSet: IDead; | ||
abstract readonly doneSet: IDone; | ||
abstract queue(queueName: string): IQueue; | ||
@@ -49,3 +48,2 @@ perform(jobType: ConstructableJobBase, ...args: any[]): Promise<string>; | ||
abstract withDeadSet<T>(fn: (dead: IDead) => Promise<T>): Promise<T>; | ||
abstract withDoneSet<T>(fn: (done: IDone) => Promise<T>): Promise<T>; | ||
abstract getQueueInfo(): Promise<Array<QueueInfo>>; | ||
@@ -52,0 +50,0 @@ abstract getWorkerInfo(): Promise<Array<WorkerInfo>>; |
@@ -37,3 +37,1 @@ import { JobDescriptor, JobDescriptorOrId } from "../JobMetadata"; | ||
} | ||
export interface IDone extends IJobSortedSet { | ||
} |
@@ -6,3 +6,3 @@ { | ||
"repository": "github:eropple/taskbotjs", | ||
"version": "0.1.0-alpha.5", | ||
"version": "0.9.0", | ||
"main": "dist", | ||
@@ -9,0 +9,0 @@ "files": [ |
@@ -25,3 +25,3 @@ import _ from "lodash"; | ||
import { IQueue } from "../ClientBase/IQueue"; | ||
import { RetryJobSortedSet, ScheduledJobSortedSet, DeadJobSortedSet, DoneJobSortedSet } from "./JobSortedSets"; | ||
import { RetryJobSortedSet, ScheduledJobSortedSet, DeadJobSortedSet } from "./JobSortedSets"; | ||
import { ICounter } from "../ClientBase/ICounter"; | ||
@@ -32,3 +32,2 @@ import { Counter } from "./Counter"; | ||
import { Multi } from "redis"; | ||
import { IDone } from "../ClientBase/ISortedSet"; | ||
import { ClientMiddlewarePhase, ClientMiddleware } from "../ClientMiddleware"; | ||
@@ -44,3 +43,2 @@ | ||
readonly deadSet: DeadJobSortedSet; | ||
readonly doneSet: DoneJobSortedSet; | ||
@@ -64,3 +62,2 @@ private readonly queues: { [queueName: string]: Queue } = {}; | ||
this.deadSet = new DeadJobSortedSet(this.logger, this, this.asyncRedis); | ||
this.doneSet = new DoneJobSortedSet(this.logger, this, this.asyncRedis); | ||
} | ||
@@ -163,3 +160,3 @@ | ||
const jsons = await this.asyncRedis.mget(...keys); | ||
const jsons = jobIds.length > 0 ? await this.asyncRedis.mget(...keys) : []; | ||
@@ -189,3 +186,3 @@ return Promise.all( | ||
this.logger.trace({ jobId: id }, "Deleting job."); | ||
const num = await this.asyncRedis.del(id); | ||
const num = await this.asyncRedis.del(`jobs/${id}`); | ||
@@ -213,6 +210,2 @@ if (num !== 1) { | ||
async withDoneSet<T>(fn: (done: IDone) => Promise<T>): Promise<T> { | ||
return fn(this.doneSet); | ||
} | ||
async getQueueInfo(): Promise<Array<QueueInfo>> { | ||
@@ -219,0 +212,0 @@ const keys = await this.scanAll("queue/*"); |
@@ -9,3 +9,3 @@ import * as _ from "lodash"; | ||
import { JobDescriptor, JobDescriptorOrId } from "../JobMetadata"; | ||
import { IRetries, IScheduled, IDead, IDone, IJobSortedSet } from "../ClientBase/ISortedSet"; | ||
import { IRetries, IScheduled, IDead, IJobSortedSet } from "../ClientBase/ISortedSet"; | ||
import { ScoreSortedSet } from "./ScoreSortedSet"; | ||
@@ -158,7 +158,1 @@ import { Client } from "."; | ||
} | ||
export class DoneJobSortedSet extends JobSortedSet implements IDone { | ||
constructor(baseLogger: Bunyan, client: Client, asyncRedis: AsyncRedis) { | ||
super(baseLogger, client, asyncRedis, "done", client.redisPrefix, doneScorer); | ||
} | ||
} |
@@ -18,3 +18,3 @@ import os from "os"; | ||
import { QueueInfo, StorageInfo, BasicMetrics, WorkerInfo, MetricDayRange, DurationFields } from "../domain"; | ||
import { IRetries, IDead, IScheduled, IDone } from "./ISortedSet"; | ||
import { IRetries, IDead, IScheduled } from "./ISortedSet"; | ||
export { IRetries, IDead, IScheduled } from "./ISortedSet"; | ||
@@ -94,3 +94,2 @@ | ||
abstract get deadSet(): IDead; | ||
abstract get doneSet(): IDone; | ||
abstract queue(queueName: string): IQueue; | ||
@@ -156,3 +155,2 @@ | ||
abstract async withDeadSet<T>(fn: (dead: IDead) => Promise<T>): Promise<T>; | ||
abstract async withDoneSet<T>(fn: (done: IDone) => Promise<T>): Promise<T>; | ||
@@ -159,0 +157,0 @@ abstract async getQueueInfo(): Promise<Array<QueueInfo>>; |
@@ -48,5 +48,1 @@ import { JobDescriptor, JobDescriptorOrId } from "../JobMetadata"; | ||
} | ||
export interface IDone extends IJobSortedSet { | ||
} |
149575
3336