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

Function WithScheduleTTL

jetstream/jetstream_options.go:788–796  ·  view source on GitHub ↗

WithScheduleTTL sets the TTL on messages generated by the scheduler. Requires [StreamConfig.AllowMsgTTL] to be enabled on the stream.

(d time.Duration)

Source from the content-addressed store, hash-verified

786// WithScheduleTTL sets the TTL on messages generated by the scheduler.
787// Requires [StreamConfig.AllowMsgTTL] to be enabled on the stream.
788func WithScheduleTTL(d time.Duration) PublishOpt {
789 return func(opts *pubOpts) error {
790 if d <= 0 {
791 return fmt.Errorf("%w: schedule TTL must be greater than 0", ErrInvalidOption)
792 }
793 opts.scheduleTTL = d.String()
794 return nil
795 }
796}
797
798// WithScheduleTTLNever marks messages generated by the scheduler as never
799// expiring. This overrides the stream's MaxAge for delivered messages.

Callers 1

Calls 2

ErrorfMethod · 0.80
StringMethod · 0.45

Tested by 1