-
-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathsubscription.ts
More file actions
23 lines (21 loc) · 855 Bytes
/
subscription.ts
File metadata and controls
23 lines (21 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import type { Binary } from "./protocol/shared/types.ts";
export type DefaultPubSubMessageType = string;
export type PubSubMessageType = string | string[];
export type SubscribeCommand = "SUBSCRIBE" | "PSUBSCRIBE";
export interface RedisPubSubMessage<TMessage = DefaultPubSubMessageType> {
pattern?: string;
channel: string;
message: TMessage;
}
export interface RedisSubscription<
TMessage extends PubSubMessageType = DefaultPubSubMessageType,
> {
readonly isClosed: boolean;
receive(): AsyncIterableIterator<RedisPubSubMessage<TMessage>>;
receiveBuffers(): AsyncIterableIterator<RedisPubSubMessage<Binary>>;
psubscribe(...patterns: string[]): Promise<void>;
subscribe(...channels: string[]): Promise<void>;
punsubscribe(...patterns: string[]): Promise<void>;
unsubscribe(...channels: string[]): Promise<void>;
close(): void;
}