|
1 | | -import type { CommandExecutor } from "./executor.ts"; |
| 1 | +import type { Client } from "./client.ts"; |
2 | 2 | import { isRetriableError } from "./errors.ts"; |
3 | 3 | import type { Binary } from "./protocol/shared/types.ts"; |
4 | 4 | import { decoder } from "./internal/encoding.ts"; |
@@ -33,17 +33,17 @@ class RedisSubscriptionImpl< |
33 | 33 | TMessage extends ValidMessageType = DefaultMessageType, |
34 | 34 | > implements RedisSubscription<TMessage> { |
35 | 35 | get isConnected(): boolean { |
36 | | - return this.executor.connection.isConnected; |
| 36 | + return this.client.connection.isConnected; |
37 | 37 | } |
38 | 38 |
|
39 | 39 | get isClosed(): boolean { |
40 | | - return this.executor.connection.isClosed; |
| 40 | + return this.client.connection.isClosed; |
41 | 41 | } |
42 | 42 |
|
43 | 43 | private channels = Object.create(null); |
44 | 44 | private patterns = Object.create(null); |
45 | 45 |
|
46 | | - constructor(private executor: CommandExecutor) {} |
| 46 | + constructor(private client: Client) {} |
47 | 47 |
|
48 | 48 | async psubscribe(...patterns: string[]) { |
49 | 49 | await this.#writeCommand("PSUBSCRIBE", patterns); |
@@ -89,7 +89,7 @@ class RedisSubscriptionImpl< |
89 | 89 | RedisPubSubMessage<T> |
90 | 90 | > { |
91 | 91 | let forceReconnect = false; |
92 | | - const connection = this.executor.connection; |
| 92 | + const connection = this.client.connection; |
93 | 93 | while (this.isConnected) { |
94 | 94 | try { |
95 | 95 | let rep: [string | Binary, string | Binary, T] | [ |
@@ -156,32 +156,32 @@ class RedisSubscriptionImpl< |
156 | 156 | } |
157 | 157 |
|
158 | 158 | close() { |
159 | | - this.executor.connection.close(); |
| 159 | + this.client.connection.close(); |
160 | 160 | } |
161 | 161 |
|
162 | 162 | async #writeCommand(command: string, args: Array<string>): Promise<void> { |
163 | | - await this.executor.connection[kUnstableWriteCommand]({ command, args }); |
| 163 | + await this.client.connection[kUnstableWriteCommand]({ command, args }); |
164 | 164 | } |
165 | 165 | } |
166 | 166 |
|
167 | 167 | export async function subscribe< |
168 | 168 | TMessage extends ValidMessageType = DefaultMessageType, |
169 | 169 | >( |
170 | | - executor: CommandExecutor, |
| 170 | + client: Client, |
171 | 171 | ...channels: string[] |
172 | 172 | ): Promise<RedisSubscription<TMessage>> { |
173 | | - const sub = new RedisSubscriptionImpl<TMessage>(executor); |
| 173 | + const sub = new RedisSubscriptionImpl<TMessage>(client); |
174 | 174 | await sub.subscribe(...channels); |
175 | 175 | return sub; |
176 | 176 | } |
177 | 177 |
|
178 | 178 | export async function psubscribe< |
179 | 179 | TMessage extends ValidMessageType = DefaultMessageType, |
180 | 180 | >( |
181 | | - executor: CommandExecutor, |
| 181 | + client: Client, |
182 | 182 | ...patterns: string[] |
183 | 183 | ): Promise<RedisSubscription<TMessage>> { |
184 | | - const sub = new RedisSubscriptionImpl<TMessage>(executor); |
| 184 | + const sub = new RedisSubscriptionImpl<TMessage>(client); |
185 | 185 | await sub.psubscribe(...patterns); |
186 | 186 | return sub; |
187 | 187 | } |
0 commit comments