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

Function New

jetstream/jetstream.go:470–491  ·  view source on GitHub ↗

New returns a new JetStream instance. It uses default API prefix ($JS.API) for JetStream API requests. If a custom API prefix is required, use [NewWithAPIPrefix] or [NewWithDomain]. Available options: - [WithClientTrace] - enables request/response tracing. - [WithPublishAsyncErrHandler] - sets erro

(nc *nats.Conn, opts ...JetStreamOpt)

Source from the content-addressed store, hash-verified

468// - [WithPublishAsyncMaxPending] - sets the maximum outstanding async publishes
469// that can be inflight at one time.
470func New(nc *nats.Conn, opts ...JetStreamOpt) (JetStream, error) {
471 jsOpts := JetStreamOptions{
472 apiPrefix: DefaultAPIPrefix,
473 publisherOpts: asyncPublisherOpts{
474 maxpa: defaultAsyncPubAckInflight,
475 },
476 DefaultTimeout: defaultAPITimeout,
477 }
478 setReplyPrefix(nc, &jsOpts)
479 for _, opt := range opts {
480 if err := opt(&jsOpts); err != nil {
481 return nil, err
482 }
483 }
484 js := &jetStream{
485 conn: nc,
486 opts: jsOpts,
487 publisher: &jetStreamClient{asyncPublisherOpts: jsOpts.publisherOpts},
488 }
489
490 return js, nil
491}
492
493const (
494 // defaultAsyncPubAckInflight is the number of async pub acks inflight.

Calls 1

setReplyPrefixFunction · 0.85