diff --git a/cloudflare/queues/batchsendoptions.go b/cloudflare/queues/batchsendoptions.go new file mode 100644 index 0000000..97abd6d --- /dev/null +++ b/cloudflare/queues/batchsendoptions.go @@ -0,0 +1,36 @@ +package queues + +import ( + "syscall/js" + "time" + + "github.com/syumai/workers/internal/jsutil" +) + +type batchSendOptions struct { + // DelaySeconds - The number of seconds to delay the message. + // Default is 0 + DelaySeconds int +} + +func (o *batchSendOptions) toJS() js.Value { + if o == nil { + return js.Undefined() + } + + obj := jsutil.NewObject() + if o.DelaySeconds != 0 { + obj.Set("delaySeconds", o.DelaySeconds) + } + + return obj +} + +type BatchSendOption func(*batchSendOptions) + +// WithBatchDelay changes the number of seconds to delay the message. +func WithBatchDelay(d time.Duration) BatchSendOption { + return func(o *batchSendOptions) { + o.DelaySeconds = int(d.Seconds()) + } +} diff --git a/cloudflare/queues/producer_opts.go b/cloudflare/queues/producer_opts.go index cf2c5db..c6501e9 100644 --- a/cloudflare/queues/producer_opts.go +++ b/cloudflare/queues/producer_opts.go @@ -36,31 +36,3 @@ func WithDelay(d time.Duration) SendOption { o.DelaySeconds = int(d.Seconds()) } } - -type batchSendOptions struct { - // DelaySeconds - The number of seconds to delay the message. - // Default is 0 - DelaySeconds int -} - -func (o *batchSendOptions) toJS() js.Value { - if o == nil { - return js.Undefined() - } - - obj := jsutil.NewObject() - if o.DelaySeconds != 0 { - obj.Set("delaySeconds", o.DelaySeconds) - } - - return obj -} - -type BatchSendOption func(*batchSendOptions) - -// WithBatchDelay changes the number of seconds to delay the message. -func WithBatchDelay(d time.Duration) BatchSendOption { - return func(o *batchSendOptions) { - o.DelaySeconds = int(d.Seconds()) - } -}