@@ -110,13 +110,43 @@ import {
110
110
import { nuid } from "../nats-base-client/nuid.ts" ;
111
111
import { DirectStreamAPIImpl } from "./jsm.ts" ;
112
112
113
+ /**
114
+ * Returns a {@link JetStreamClient} supported by the specified NatsConnection
115
+ * @param nc
116
+ * @param opts
117
+ */
113
118
export function jetstream (
114
119
nc : NatsConnection ,
115
120
opts : JetStreamManagerOptions = { } ,
116
121
) : JetStreamClient {
117
122
return new JetStreamClientImpl ( nc , opts ) ;
118
123
}
119
124
125
+
126
+ /**
127
+ * Returns a {@link JetStreamManager} supported by the specified NatsConnection
128
+ * @param nc
129
+ * @param opts
130
+ */
131
+ export async function jetstreamManager (
132
+ nc : NatsConnection ,
133
+ opts : JetStreamOptions | JetStreamManagerOptions = { } ,
134
+ ) : Promise < JetStreamManager > {
135
+ const adm = new JetStreamManagerImpl ( nc , opts ) ;
136
+ if ( ( opts as JetStreamManagerOptions ) . checkAPI !== false ) {
137
+ try {
138
+ await adm . getAccountInfo ( ) ;
139
+ } catch ( err ) {
140
+ const ne = err as NatsError ;
141
+ if ( ne . code === ErrorCode . NoResponders ) {
142
+ ne . code = ErrorCode . JetStreamNotEnabled ;
143
+ }
144
+ throw ne ;
145
+ }
146
+ }
147
+ return adm ;
148
+ }
149
+
120
150
class ViewsImpl implements Views {
121
151
js : JetStreamClientImpl ;
122
152
constructor ( js : JetStreamClientImpl ) {
@@ -158,25 +188,6 @@ class ViewsImpl implements Views {
158
188
}
159
189
}
160
190
161
- export async function jetstreamManager (
162
- nc : NatsConnection ,
163
- opts : JetStreamOptions | JetStreamManagerOptions = { } ,
164
- ) : Promise < JetStreamManager > {
165
- const adm = new JetStreamManagerImpl ( nc , opts ) ;
166
- if ( ( opts as JetStreamManagerOptions ) . checkAPI !== false ) {
167
- try {
168
- await adm . getAccountInfo ( ) ;
169
- } catch ( err ) {
170
- const ne = err as NatsError ;
171
- if ( ne . code === ErrorCode . NoResponders ) {
172
- ne . code = ErrorCode . JetStreamNotEnabled ;
173
- }
174
- throw ne ;
175
- }
176
- }
177
- return adm ;
178
- }
179
-
180
191
export class JetStreamManagerImpl extends BaseApiClientImpl
181
192
implements JetStreamManager {
182
193
streams : StreamAPI ;
0 commit comments