-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoption.go
52 lines (42 loc) · 1.09 KB
/
option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package idemgotent
import (
"time"
"github.com/ezraisw/wracha/adapter"
"github.com/ezraisw/wracha/logger"
)
type MiddlewareOption func(*idempotencyMiddleware)
func WithAdapter(adapter adapter.Adapter) MiddlewareOption {
return func(m *idempotencyMiddleware) {
m.adapter = adapter
}
}
func WithLogger(logger logger.Logger) MiddlewareOption {
return func(m *idempotencyMiddleware) {
m.logger = logger
}
}
func WithTTL(ttl time.Duration) MiddlewareOption {
return func(m *idempotencyMiddleware) {
m.ttl = ttl
}
}
func WithKeySource(keySource KeySource) MiddlewareOption {
return func(m *idempotencyMiddleware) {
m.keySource = keySource
}
}
func WithClientErrHandler(clientErrHandler ErrHandler) MiddlewareOption {
return func(m *idempotencyMiddleware) {
m.clientErrHandler = clientErrHandler
}
}
func WithServerErrHandler(serverErrHandler ErrHandler) MiddlewareOption {
return func(m *idempotencyMiddleware) {
m.serverErrHandler = serverErrHandler
}
}
func WithResponder(responder Responder) MiddlewareOption {
return func(m *idempotencyMiddleware) {
m.responder = responder
}
}