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

Function WithScheduleCron

jetstream/jetstream_options.go:748–756  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

746// [ScheduleDaily]).
747// Requires [StreamConfig.AllowMsgSchedules] to be enabled.
748func 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.

Callers 3

TestScheduleCronDeliveryFunction · 0.92

Calls 1

ErrorfMethod · 0.80

Tested by 3

TestScheduleCronDeliveryFunction · 0.74