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

Function WithScheduleEvery

jetstream/jetstream_options.go:733–741  ·  view source on GitHub ↗

WithScheduleEvery schedules a message for repeated delivery at the given interval. The minimum interval is 1 second. Requires [StreamConfig.AllowMsgSchedules] to be enabled.

(d time.Duration)

Source from the content-addressed store, hash-verified

731// interval. The minimum interval is 1 second.
732// Requires [StreamConfig.AllowMsgSchedules] to be enabled.
733func WithScheduleEvery(d time.Duration) PublishOpt {
734 return func(opts *pubOpts) error {
735 if d < time.Second {
736 return fmt.Errorf("%w: schedule interval must be at least 1s", ErrInvalidOption)
737 }
738 opts.schedule = "@every " + d.String()
739 return nil
740 }
741}
742
743// WithScheduleCron schedules a message using a cron expression.
744// Accepts 6-field cron format (seconds minutes hours day-of-month month

Calls 2

ErrorfMethod · 0.80
StringMethod · 0.45

Tested by 5