MCPcopy
hub / github.com/nats-io/nats.go / JetStream

Method JetStream

js.go:309–331  ·  view source on GitHub ↗

JetStream returns a JetStreamContext for messaging and stream management. Errors are only returned if inconsistent options are provided. NOTE: JetStreamContext is part of legacy API. Users are encouraged to switch to the new JetStream API for enhanced capabilities and simplified API. Please refer t

(opts ...JSOpt)

Source from the content-addressed store, hash-verified

307// simplified API. Please refer to the `jetstream` package.
308// See: https://github.com/nats-io/nats.go/blob/main/jetstream/README.md
309func (nc *Conn) JetStream(opts ...JSOpt) (JetStreamContext, error) {
310 js := &js{
311 nc: nc,
312 opts: &jsOpts{
313 pre: defaultAPIPrefix,
314 wait: defaultRequestWait,
315 maxpa: defaultAsyncPubAckInflight,
316 },
317 }
318 inboxPrefix := InboxPrefix
319 if js.nc.Opts.InboxPrefix != _EMPTY_ {
320 inboxPrefix = js.nc.Opts.InboxPrefix + "."
321 }
322 js.replyPrefix = inboxPrefix
323 js.replyPrefixLen = len(js.replyPrefix) + aReplyTokensize + 1
324
325 for _, opt := range opts {
326 if err := opt.configureJSContext(js.opts); err != nil {
327 return nil, err
328 }
329 }
330 return js, nil
331}
332
333// JSOpt configures a JetStreamContext.
334type JSOpt interface {

Callers 15

PutMethod · 0.80
ExampleJetStreamFunction · 0.80
ExampleJSOptFunction · 0.80
ExampleJetStreamManagerFunction · 0.80
ExampleJetStreamContextFunction · 0.80
ExamplePubOptFunction · 0.80
ExampleSubOptFunction · 0.80
ExampleMaxWaitFunction · 0.80
ExampleAckWaitFunction · 0.80
ExampleMsg_AckSyncFunction · 0.80
ExampleMsg_MetadataFunction · 0.80
ExampleAckOptFunction · 0.80

Calls 1

configureJSContextMethod · 0.65

Tested by 15

ExampleJetStreamFunction · 0.64
ExampleJSOptFunction · 0.64
ExampleJetStreamManagerFunction · 0.64
ExampleJetStreamContextFunction · 0.64
ExamplePubOptFunction · 0.64
ExampleSubOptFunction · 0.64
ExampleMaxWaitFunction · 0.64
ExampleAckWaitFunction · 0.64
ExampleMsg_AckSyncFunction · 0.64
ExampleMsg_MetadataFunction · 0.64
ExampleAckOptFunction · 0.64
ExamplePullOptFunction · 0.64