Last active
January 21, 2017 16:33
-
-
Save drudge/724f253f232d6ef49e1e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference path="../node/node.d.ts" /> | |
/// <reference path="../redis/redis.d.ts" /> | |
declare module "node-resque" { | |
import events = require('events'); | |
import redis = require('redis'); | |
interface WorkerOptions { | |
name?: string; | |
queues?: string[]|string; | |
timeout?: number; | |
looping?: boolean; | |
connection?: ConnectionOptions; | |
} | |
interface MultiWorkerOptions { | |
minTaskProcessors?: number; | |
maxTaskProcessors?: number; | |
timeout?: number; | |
checkTimeout?: number; | |
maxEventLoopDelay?: number; | |
toDisconnectProcessors?: boolean; | |
name?: string; | |
connection?: ConnectionOptions; | |
queues?: string[]|string; | |
} | |
interface WorkerFailurePayload { | |
worker: string | |
queue: string | |
payload: any | |
exception: string | |
error: string | |
backtrace: string | |
failed_at: string | |
} | |
interface QueueOptions { | |
connection: ConnectionOptions; | |
} | |
interface SchedulerOptions { | |
connection?: ConnectionOptions; | |
timeout?: number; | |
} | |
interface ConnectionOptions { | |
package?: string | |
host?: string | |
password?: string | |
port?: number | |
database?: number | |
namespace?: string | |
} | |
interface Worker extends events.EventEmitter { | |
options: WorkerOptions; | |
jobs: Object; | |
name: string; | |
error?: Error; | |
ready: boolean; | |
runing: boolean; | |
working: boolean; | |
job: any; | |
runPlugin: any; | |
runPlugins: any; | |
queueObject: Queue; | |
connection: Connection; | |
new (options?: WorkerOptions, jobs?: Object, callback?: Function); | |
defaults(): WorkerOptions; | |
start(): void; | |
end(fn?: Function): void; | |
poll(nQueue?: number, callback?: Function): void; | |
perform(job: any, callback: Function): void; | |
completeJob(result: any, toResponse: boolean, callback: Function): void; | |
succeed(result: any, job: any): void; | |
fail(err: Error, job: any): void; | |
pause(): void; | |
workingOn(job: any): void; | |
doneWorking(): void; | |
track(callback?: Function): void; | |
untrack(name: string, queues: string[], callback?: Function): void; | |
init(callback?: Function): void; | |
workerCleanup(callback?: Function): void; | |
getPids(callback: Function): void; | |
checkQueues(callback?: Function): void; | |
failurePayload(err: Error, job: any): WorkerFailurePayload; | |
stringQueues(): string; | |
prepareJobs(jobs: any): Object; | |
} | |
interface MultiWorker extends events.EventEmitter { | |
workers: Worker[]; | |
options: MultiWorkerOptions; | |
jobs: Object; | |
runing: boolean; | |
working: boolean; | |
name: string; | |
eventLoopBlocked: boolean; | |
eventLoopCheckCounter: number; | |
eventLoopDelay: number; | |
new (options?: MultiWorkerOptions, jobs?: Object, callback?: Function); | |
defaults(): MultiWorkerOptions; | |
startWorker(callback: Function): void; | |
checkWorkers(callback: Function): void; | |
cleanupWorker(worker: Worker): void; | |
checkWraper(): void; | |
start(callback?: Function): void; | |
stop(callback?: Function): void; | |
end(callback?: Function): void; | |
stopWait(callback?: Function): void; | |
} | |
interface Queue { | |
options: QueueOptions; | |
jobs: any; | |
queueObject: Queue; | |
runPlugin: any; | |
runPlugins: any; | |
connection: Connection; | |
new (options?: QueueOptions, jobs?: Object, callback?: Function); | |
end(fn?: Function): void; | |
encode(q: string, func: string, args?: any[]): string; | |
enqueue(q: string, func: string, args?: any[], callback?: Function); | |
enqueueAt(timestamp: number, q: string, func: string, args?: any[], callback?: Function); | |
enqueueIn(time: number, q: string, func: string, args?: any[], callback?: Function); | |
queues(callback: Function): void; | |
delQueue(q: string, callback: Function): void; | |
length(q: string, callback: Function): void; | |
del(q: string, func: string, args?: any[], count?: number, callback?: Function): void; | |
delDelayed(q: string, func: string, args?: any[], callback?: Function): void; | |
scheduleAt(q: string, func: string, args?: any[], callback?: Function): void; | |
timestamps(callback: Function): void; | |
delayedat(timestamp: number, callback: Function): void; | |
queued(q: string, start: any, stop: any, callback: Function): void; | |
allDelayed(callback: Function): void; | |
workers(callback?: Function): void; | |
workingOn(workerName: string, queues: string[], callback?: Function): void; | |
allWorkingOn(callback: Function): void; | |
forceCleanWorker(workerName: string, callback: Function): void; | |
cleanOldWorkers(age: number, callback?: Function): void; | |
failedCount(callback: Function): void; | |
failed(start: any, stop: any, callback: Function): void; | |
removeFailed(failedJob: any, callback: Function): void; | |
retryAndRemoveFailed(failedJob: any, callback: Function): void; | |
} | |
interface Scheduler extends events.EventEmitter { | |
options: SchedulerOptions; | |
connection: Connection; | |
running: boolean; | |
queue: Queue; | |
new (options?: SchedulerOptions, jobs?: Object, callback?: Function); | |
defaults(): SchedulerOptions; | |
start(): void; | |
end(callback?: Function): void; | |
poll(callback?: Function): void; | |
nextDelayedTimestamp(callback: Function); | |
enqueueDelayedItemsForTimestamp(timestamp: number, callback: Function): void; | |
nextItemForTimestamp(timestamp: number, callback: Function): void; | |
transfer(timestamp: number, job: any, callback: Function): void; | |
cleanupTimestamp(timestamp: number, callback: Function): void; | |
} | |
interface Connection { | |
options: ConnectionOptions; | |
connected: boolean; | |
redis: redis.RedisClient; | |
new (options: ConnectionOptions); | |
defaults(): ConnectionOptions; | |
ensureConnected(parentCallback: Function, callack: Function): void; | |
connect(callback: Function): void; | |
disconnect(): void; | |
key(): string; | |
} | |
export var worker: Worker; | |
export var queue: Queue; | |
export var scheduler: Scheduler; | |
export var connection: Connection; | |
export var multiWorker: MultiWorker; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment