forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rabbit.js.d.ts
108 lines (88 loc) · 3.34 KB
/
rabbit.js.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Type definitions for rabbit.js v0.4.2
// Project: https://github.com/squaremo/rabbit.js
// Definitions by: Wonshik Kim <https://github.com/wokim>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module "rabbit.js" {
import events = require('events');
import stream = require('stream');
export function createContext(url?: string): Context;
export class Context extends events.EventEmitter {
public socket<T>(type: string, options?: SocketOptions):T;
public close(callback: Function): any;
}
export interface SocketOptions {
prefetch?: any;
expiration?: any;
persistent?: any;
topic?: any;
task?: any;
}
export interface Socket {
connect(destination: string, callback?: Function): any;
setsockopt(opt: string, value: string): any;
close(): any;
}
export class PubSocket extends stream.Writable implements Socket {
constructor(channel: string, opts: SocketOptions);
connect(destination: string, callback?: Function): any;
setsockopt(opt: string, value: string): any;
close(): any;
publish(topic: string, chunk: string, encoding?: string): any;
publish(topic: string, chunk: Buffer, encoding?: string): any;
}
export class SubSocket extends stream.Readable implements Socket {
constructor(channel: string, opts: SocketOptions);
connect(source: string, callback?: Function): any;
setsockopt(opt: string, value: string): any;
close(): any;
}
export class PushSocket extends stream.Writable implements Socket {
constructor(channel: string, opts: SocketOptions);
connect(destination: string, callback?: Function): any;
setsockopt(opt: string, value: string): any;
close(): any;
}
export class PullSocket extends stream.Readable implements Socket {
constructor(channel: string, opts: SocketOptions);
connect(source: string, callback?: Function): any;
setsockopt(opt: string, value: string): any;
close(): any;
}
export class WorkerSocket extends stream.Readable implements Socket {
constructor(channel: string, opts: SocketOptions);
connect(source: string, callback?: Function): any;
setsockopt(opt: string, value: string): any;
close(): any;
ack(): any;
requeue(): any;
discard(): any;
}
export interface RequestMessage {
properties: { correlationId: number };
content: any;
}
export class ReqSocket extends stream.Duplex implements Socket {
constructor(channel: string, opts: SocketOptions);
connect(destination: string, callback?: Function): any;
setsockopt(opt: string, value: string): any;
close(): any;
handleReply(msg: RequestMessage): any;
}
export class RepSocket extends stream.Duplex implements Socket {
constructor(channel: string, opts: SocketOptions);
connect(source: string, callback?: Function): any;
setsockopt(opt: string, value: string): any;
close(): any;
requeue(): any;
discard(): any;
}
export class TaskSocket extends stream.Writable implements Socket {
constructor(channel: string, opts: SocketOptions);
connect(destination: string, callback?: Function): any;
setsockopt(opt: string, value: string): any;
close(): any;
post(task: string, chunk: string, encoding?: string): any;
post(task: string, chunk: Buffer, encoding?: string): any;
}
}