-
Notifications
You must be signed in to change notification settings - Fork 2
/
util.go
47 lines (35 loc) · 964 Bytes
/
util.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
package grpc
import (
"reflect"
"google.golang.org/grpc"
)
func prependServerOption(
newInterceptor grpc.UnaryServerInterceptor,
interceptors []grpc.UnaryServerInterceptor,
) []grpc.UnaryServerInterceptor {
newInterceptors := make(
[]grpc.UnaryServerInterceptor,
len(interceptors)+1,
)
copy(newInterceptors[1:], interceptors)
newInterceptors[0] = newInterceptor
return newInterceptors
}
func isErrorHandlerNil(errorHandler ErrorHandler) bool {
c := errorHandler
return c == nil ||
(reflect.ValueOf(c).Kind() == reflect.Ptr &&
reflect.ValueOf(c).IsNil())
}
func isPanicHandlerNil(panicHandler PanicHandler) bool {
c := panicHandler
return c == nil ||
(reflect.ValueOf(c).Kind() == reflect.Ptr &&
reflect.ValueOf(c).IsNil())
}
func isMonitorOperationerNil(monitorOperationer MonitorOperationer) bool {
c := monitorOperationer
return c == nil ||
(reflect.ValueOf(c).Kind() == reflect.Ptr &&
reflect.ValueOf(c).IsNil())
}