-
Notifications
You must be signed in to change notification settings - Fork 2
/
io.d.ts
78 lines (49 loc) · 2.78 KB
/
io.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
import type { Readable } from 'node:stream'
import type { EventEmitter } from 'node:events'
import * as _diagnostics from './diagnostic'
import * as _encoding from './encoding'
import * as _topology from './topology'
import * as _amqp from './amqp'
declare namespace comq {
type Producer<Input = any, Output = any> = (message: Input) => Output | Promise<Output>
type Consumer<T = any> = (message: T, headers?: _amqp.Properties) => void | Promise<void>
interface ReplyEmitter extends EventEmitter {
readonly queue: string
}
interface Destroyable extends EventEmitter {
destroy (): void
}
interface Request {
buffer: Buffer
emitter: ReplyEmitter
properties: _amqp.Properties
}
interface IO extends _diagnostics.Diagnosable {
reply (queue: string, produce: Producer): Promise<void>
request<Reply = any, Request = any> (queue: string, payload: Request, encoding?: _encoding.Encoding): Promise<Reply> | Promise<Readable>
request (queue: string, stream: Readable, encoding?: _encoding.Encoding): Promise<Readable>
consume<T = any> (exchange: string, group: string, consumer: Consumer<T>): Promise<void>
consume<T = any> (exchange: string, consumer: Consumer<T>): Promise<void>
emit (exchange: string, payload: any, encoding?: _encoding.Encoding): Promise<void>
emit (exchange: string, payload: any, properties?: _amqp.Properties): Promise<void>
emit (exchange: string, stream: Readable, encoding?: _encoding.Encoding): Promise<void>
emit (exchange: string, stream: Readable, properties?: _amqp.Properties): Promise<void>
enqueue (exchange: string, payload: any, encoding?: _encoding.Encoding): Promise<void>
enqueue (exchange: string, payload: any, properties?: _amqp.Properties): Promise<void>
enqueue (exchange: string, stream: Readable, encoding?: _encoding.Encoding): Promise<void>
enqueue (exchange: string, stream: Readable, properties?: _amqp.Properties): Promise<void>
process<T = any> (queue: string, processor: Consumer<T>): Promise<void>
seal (): Promise<void>
close (): Promise<void>
diagnose (event: 'open', listener: (index?: number) => void): void
diagnose (event: 'close', listener: (index?: number) => void): void
diagnose (event: 'flow', listener: (channel: _topology.type, index?: number) => void): void
diagnose (event: 'drain', listener: (channel: _topology.type, index?: number) => void): void
diagnose (event: 'remove', listener: (index?: number) => void): void
diagnose (event: 'recover', listener: (channel: _topology.type, index?: number) => void): void
diagnose (event: 'discard', listener: (channel: _topology.type, message: any, index?: number) => void): void
}
}
export type Producer = comq.Producer
export type Consumer = comq.Consumer
export type IO = comq.IO