Skip to content

Commit

Permalink
WithIdempotencyKey option
Browse files Browse the repository at this point in the history
  • Loading branch information
FZambia committed Nov 19, 2023
1 parent d23f1a0 commit 2b7c2c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ func WithHistory(size int, ttl time.Duration, metaTTL ...time.Duration) PublishO
}
}

// WithIdempotencyKey tells Broker the idempotency key for the publication.
// See PublishOptions.IdempotencyKey.
func WithIdempotencyKey(key string) PublishOption {
return func(opts *PublishOptions) {
opts.IdempotencyKey = key
}
}

// WithClientInfo adds ClientInfo to Publication.
func WithClientInfo(info *ClientInfo) PublishOption {
return func(opts *PublishOptions) {
Expand Down
7 changes: 7 additions & 0 deletions options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ func TestWithHistory(t *testing.T) {
require.Equal(t, time.Second, opts.HistoryTTL)
}

func TestWithIdempotencyKey(t *testing.T) {
opt := WithIdempotencyKey("ik")
opts := &PublishOptions{}
opt(opts)
require.Equal(t, "ik", opts.IdempotencyKey)
}

func TestWithMeta(t *testing.T) {
opt := WithTags(map[string]string{"test": "value"})
opts := &PublishOptions{}
Expand Down

0 comments on commit 2b7c2c7

Please sign in to comment.