NewWithDomain returns a new JetStream instance and sets the domain name token used when sending JetStream requests. The domain name token will be used in API requests to JetStream, e.g. $JS.<domain>.API.STREAM.INFO.<stream>. Available options: - [WithClientTrace] - enables request/response tracing.
(nc *nats.Conn, domain string, opts ...JetStreamOpt)
| 552 | // - [WithPublishAsyncMaxPending] - sets the maximum outstanding async publishes |
| 553 | // that can be inflight at one time. |
| 554 | func NewWithDomain(nc *nats.Conn, domain string, opts ...JetStreamOpt) (JetStream, error) { |
| 555 | jsOpts := JetStreamOptions{ |
| 556 | publisherOpts: asyncPublisherOpts{ |
| 557 | maxpa: defaultAsyncPubAckInflight, |
| 558 | }, |
| 559 | Domain: domain, |
| 560 | DefaultTimeout: defaultAPITimeout, |
| 561 | } |
| 562 | setReplyPrefix(nc, &jsOpts) |
| 563 | for _, opt := range opts { |
| 564 | if err := opt(&jsOpts); err != nil { |
| 565 | return nil, err |
| 566 | } |
| 567 | } |
| 568 | if domain == "" { |
| 569 | return nil, errors.New("domain cannot be empty") |
| 570 | } |
| 571 | jsOpts.apiPrefix = fmt.Sprintf(jsDomainT, domain) |
| 572 | js := &jetStream{ |
| 573 | conn: nc, |
| 574 | opts: jsOpts, |
| 575 | publisher: &jetStreamClient{asyncPublisherOpts: jsOpts.publisherOpts}, |
| 576 | } |
| 577 | return js, nil |
| 578 | } |
| 579 | |
| 580 | // Conn returns the underlying NATS connection. |
| 581 | func (js *jetStream) Conn() *nats.Conn { |