@@ -37,98 +37,6 @@ extension ValkeyClusterClient {
37
37
return try await operation ( connection)
38
38
}
39
39
40
- /// Subscribe to list of channels and run closure with subscription
41
- ///
42
- /// When the closure is exited the channels are automatically unsubscribed from.
43
- ///
44
- /// When running subscribe from `ValkeyClient` a single connection is used for
45
- /// all subscriptions.
46
- ///
47
- /// - Parameters:
48
- /// - channels: list of channels to subscribe to
49
- /// - isolation: Actor isolation
50
- /// - process: Closure that is called with subscription async sequence
51
- /// - Returns: Return value of closure
52
- @inlinable
53
- public func subscribe< Value> (
54
- to channels: String ... ,
55
- isolation: isolated ( any Actor ) ? = #isolation,
56
- process: ( ValkeySubscription ) async throws -> sending Value
57
- ) async throws -> sending Value {
58
- try await self . subscribe ( to: channels, process: process)
59
- }
60
-
61
- @inlinable
62
- /// Subscribe to list of channels and run closure with subscription
63
- ///
64
- /// When the closure is exited the channels are automatically unsubscribed from.
65
- ///
66
- /// When running subscribe from `ValkeyClient` a single connection is used for
67
- /// all subscriptions.
68
- ///
69
- /// - Parameters:
70
- /// - channels: list of channels to subscribe to
71
- /// - isolation: Actor isolation
72
- /// - process: Closure that is called with subscription async sequence
73
- /// - Returns: Return value of closure
74
- public func subscribe< Value> (
75
- to channels: [ String ] ,
76
- isolation: isolated ( any Actor ) ? = #isolation,
77
- process: ( ValkeySubscription ) async throws -> sending Value
78
- ) async throws -> sending Value {
79
- try await self . subscribe (
80
- command: SUBSCRIBE ( channels: channels) ,
81
- filters: channels. map { . channel( $0) } ,
82
- process: process
83
- )
84
- }
85
-
86
- /// Subscribe to list of channel patterns and run closure with subscription
87
- ///
88
- /// When the closure is exited the patterns are automatically unsubscribed from.
89
- ///
90
- /// When running subscribe from `ValkeyClient` a single connection is used for
91
- /// all subscriptions.
92
- ///
93
- /// - Parameters:
94
- /// - patterns: list of channel patterns to subscribe to
95
- /// - isolation: Actor isolation
96
- /// - process: Closure that is called with subscription async sequence
97
- /// - Returns: Return value of closure
98
- @inlinable
99
- public func psubscribe< Value> (
100
- to patterns: String ... ,
101
- isolation: isolated ( any Actor ) ? = #isolation,
102
- process: ( ValkeySubscription ) async throws -> sending Value
103
- ) async throws -> sending Value {
104
- try await self . psubscribe ( to: patterns, process: process)
105
- }
106
-
107
- /// Subscribe to list of pattern matching channels and run closure with subscription
108
- ///
109
- /// When the closure is exited the patterns are automatically unsubscribed from.
110
- ///
111
- /// When running subscribe from `ValkeyClient` a single connection is used for
112
- /// all subscriptions.
113
- ///
114
- /// - Parameters:
115
- /// - patterns: list of channel patterns to subscribe to
116
- /// - isolation: Actor isolation
117
- /// - process: Closure that is called with subscription async sequence
118
- /// - Returns: Return value of closure
119
- @inlinable
120
- public func psubscribe< Value> (
121
- to patterns: [ String ] ,
122
- isolation: isolated ( any Actor ) ? = #isolation,
123
- process: ( ValkeySubscription ) async throws -> sending Value
124
- ) async throws -> sending Value {
125
- try await self . subscribe (
126
- command: PSUBSCRIBE ( patterns: patterns) ,
127
- filters: patterns. map { . pattern( $0) } ,
128
- process: process
129
- )
130
- }
131
-
132
40
/// Subscribe to key invalidation channel required for client-side caching
133
41
///
134
42
/// See https://valkey.io/topics/client-side-caching/ for more details. The `process`
@@ -159,15 +67,20 @@ extension ValkeyClusterClient {
159
67
}
160
68
}
161
69
70
+ /// Execute subscribe command and run closure using related ``ValkeySubscription``
71
+ /// AsyncSequence
72
+ ///
73
+ /// This should not be called directly, used the related commands
74
+ /// ``ValkeyClusterClient/subscribe(to:isolation:process:)`` or
75
+ /// ``ValkeyClusterClient/psubscribe(to:isolation:process:)``
162
76
@inlinable
163
- func subscribe< Value> (
164
- command: some ValkeyCommand ,
165
- filters: [ ValkeySubscriptionFilter ] ,
77
+ public func _subscribe< Value> (
78
+ command: some ValkeySubscribeCommand ,
166
79
isolation: isolated ( any Actor ) ? = #isolation,
167
80
process: ( ValkeySubscription ) async throws -> sending Value
168
81
) async throws -> sending Value {
169
82
try await self . withSubscriptionConnection { connection in
170
- try await connection. subscribe ( command: command, filters : filters , process: process)
83
+ try await connection. _subscribe ( command: command, isolation : isolation , process: process)
171
84
}
172
85
}
173
86
}
0 commit comments