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)
| 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. |
| 72 | func 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 |