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

Function WithDefaultTimeout

jetstream/jetstream_options.go:72–80  ·  view source on GitHub ↗

WithDefaultTimeout sets the default timeout for JetStream API requests. It is used when context used for the request does not have a deadline set. If not provided, a default of 5 seconds will be used.

(timeout time.Duration)

Source from the content-addressed store, hash-verified

70// It is used when context used for the request does not have a deadline set.
71// If not provided, a default of 5 seconds will be used.
72func WithDefaultTimeout(timeout time.Duration) JetStreamOpt {
73 return func(opts *JetStreamOptions) error {
74 if timeout <= 0 {
75 return fmt.Errorf("%w: timeout value must be greater than 0", ErrInvalidOption)
76 }
77 opts.DefaultTimeout = timeout
78 return nil
79 }
80}
81
82// WithPurgeSubject sets a specific subject for which messages on a stream will
83// be purged

Callers 2

TestPublishTimeoutFunction · 0.92

Calls 1

ErrorfMethod · 0.80

Tested by 2

TestPublishTimeoutFunction · 0.74