Skip to content

Commit

Permalink
new: added option ContextOptionIdempotencyKey
Browse files Browse the repository at this point in the history
  • Loading branch information
primalmotion committed Oct 3, 2019
1 parent 56bc2de commit 58719fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,10 @@ func ContextOptionRetryRatio(r int64) ContextOption {
c.retryRatio = r
}
}

// ContextOptionIdempotencyKey sets a custom idempotency key.
func ContextOptionIdempotencyKey(key string) ContextOption {
return func(c *mcontext) {
c.idempotencyKey = key
}
}
5 changes: 5 additions & 0 deletions options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,9 @@ func TestManipulate_ContextOption(t *testing.T) {
ContextOptionRetryRatio(42)(mctx.(*mcontext))
So(mctx.RetryRatio(), ShouldEqual, 42)
})

Convey("Calling ContextOptionIdempotencyKey should work", t, func() {
ContextOptionIdempotencyKey("42")(mctx.(*mcontext))
So(mctx.(*mcontext).idempotencyKey, ShouldEqual, "42")
})
}

0 comments on commit 58719fc

Please sign in to comment.