-
Notifications
You must be signed in to change notification settings - Fork 1
/
options.go
51 lines (43 loc) · 958 Bytes
/
options.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
package interceptors
import "google.golang.org/grpc"
type clientOption interface {
grpc.CallOption
process(*clientOptions)
}
type clientOptions struct {
hystrixName string
disableHystrix bool
}
type optionCarrier struct {
grpc.EmptyCallOption
processor func(*clientOptions)
}
func (h *optionCarrier) process(co *clientOptions) {
h.processor(co)
}
//WithHystrixName changes the hystrix name to be used in the client interceptors
func WithHystrixName(name string) clientOption {
return &optionCarrier{
processor: func(co *clientOptions) {
if name != "" {
co.hystrixName = name
}
},
}
}
// WithoutHystrix disables hystrix
func WithoutHystrix() clientOption {
return &optionCarrier{
processor: func(co *clientOptions) {
co.disableHystrix = true
},
}
}
// WithHystrix enables hystrix
func WithHystrix() clientOption {
return &optionCarrier{
processor: func(co *clientOptions) {
co.disableHystrix = false
},
}
}