WithScheduleCron schedules a message using a cron expression. Accepts 6-field cron format (seconds minutes hours day-of-month month day-of-week) or predefined schedules (e.g. [ScheduleHourly], [ScheduleDaily]). Requires [StreamConfig.AllowMsgSchedules] to be enabled.
(expr string)
| 746 | // [ScheduleDaily]). |
| 747 | // Requires [StreamConfig.AllowMsgSchedules] to be enabled. |
| 748 | func WithScheduleCron(expr string) PublishOpt { |
| 749 | return func(opts *pubOpts) error { |
| 750 | if expr == "" { |
| 751 | return fmt.Errorf("%w: cron expression cannot be empty", ErrInvalidOption) |
| 752 | } |
| 753 | opts.schedule = expr |
| 754 | return nil |
| 755 | } |
| 756 | } |
| 757 | |
| 758 | // WithScheduleTarget sets the subject where scheduled messages will be |
| 759 | // delivered. |