From 374d3a8461e26bab71f0abda47326ffefe19abe8 Mon Sep 17 00:00:00 2001 From: syumai Date: Sun, 10 Nov 2024 00:07:29 +0900 Subject: [PATCH] rename queues.WithDelay to queues.WithDelaySeconds --- cloudflare/queues/batchsendoptions.go | 4 ++-- cloudflare/queues/producer_test.go | 6 +++--- cloudflare/queues/sendoptions.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cloudflare/queues/batchsendoptions.go b/cloudflare/queues/batchsendoptions.go index 97abd6d..54815bc 100644 --- a/cloudflare/queues/batchsendoptions.go +++ b/cloudflare/queues/batchsendoptions.go @@ -28,8 +28,8 @@ func (o *batchSendOptions) toJS() js.Value { type BatchSendOption func(*batchSendOptions) -// WithBatchDelay changes the number of seconds to delay the message. -func WithBatchDelay(d time.Duration) BatchSendOption { +// WithBatchDelaySeconds changes the number of seconds to delay the message. +func WithBatchDelaySeconds(d time.Duration) BatchSendOption { return func(o *batchSendOptions) { o.DelaySeconds = int(d.Seconds()) } diff --git a/cloudflare/queues/producer_test.go b/cloudflare/queues/producer_test.go index fc00a93..2903f9d 100644 --- a/cloudflare/queues/producer_test.go +++ b/cloudflare/queues/producer_test.go @@ -117,7 +117,7 @@ func TestSend_ContentTypeOption(t *testing.T) { { name: "delay", - options: []SendOption{WithDelay(5 * time.Second)}, + options: []SendOption{WithDelaySeconds(5 * time.Second)}, expectedDelaySec: 5, expectedContentType: "json", }, @@ -200,11 +200,11 @@ func TestSendBatch_Options(t *testing.T) { } var batch []*BatchMessage = []*BatchMessage{ - NewBatchMessage("hello"), + NewTextBatchMessage("hello"), } producer := validatingProducer(t, validation) - err := producer.SendBatch(batch, WithBatchDelay(5*time.Second)) + err := producer.SendBatch(batch, WithBatchDelaySeconds(5*time.Second)) if err != nil { t.Fatalf("SendBatch failed: %v", err) } diff --git a/cloudflare/queues/sendoptions.go b/cloudflare/queues/sendoptions.go index c6501e9..bc3bd85 100644 --- a/cloudflare/queues/sendoptions.go +++ b/cloudflare/queues/sendoptions.go @@ -30,8 +30,8 @@ func (o *sendOptions) toJS() js.Value { type SendOption func(*sendOptions) -// WithDelay changes the number of seconds to delay the message. -func WithDelay(d time.Duration) SendOption { +// WithDelaySeconds changes the number of seconds to delay the message. +func WithDelaySeconds(d time.Duration) SendOption { return func(o *sendOptions) { o.DelaySeconds = int(d.Seconds()) }