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)
| 731 | // interval. The minimum interval is 1 second. |
| 732 | // Requires [StreamConfig.AllowMsgSchedules] to be enabled. |
| 733 | func 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 |