Skip to content

Commit c14b90f

Browse files
committed
doc
1 parent e2738ee commit c14b90f

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

jetstream/jsclient.ts

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,43 @@ import {
110110
import { nuid } from "../nats-base-client/nuid.ts";
111111
import { DirectStreamAPIImpl } from "./jsm.ts";
112112

113+
/**
114+
* Returns a {@link JetStreamClient} supported by the specified NatsConnection
115+
* @param nc
116+
* @param opts
117+
*/
113118
export function jetstream(
114119
nc: NatsConnection,
115120
opts: JetStreamManagerOptions = {},
116121
): JetStreamClient {
117122
return new JetStreamClientImpl(nc, opts);
118123
}
119124

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+
120150
class ViewsImpl implements Views {
121151
js: JetStreamClientImpl;
122152
constructor(js: JetStreamClientImpl) {
@@ -158,25 +188,6 @@ class ViewsImpl implements Views {
158188
}
159189
}
160190

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-
180191
export class JetStreamManagerImpl extends BaseApiClientImpl
181192
implements JetStreamManager {
182193
streams: StreamAPI;

0 commit comments

Comments
 (0)