-
Notifications
You must be signed in to change notification settings - Fork 288
/
grpc.go
40 lines (34 loc) · 1.01 KB
/
grpc.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
package options
import (
"github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc"
"github.com/opentracing/opentracing-go"
"google.golang.org/grpc"
)
// 1024 MB
const MaxMsgSize int = 1024 * 1024 * 1024
func MaxMsgDial() []grpc.DialOption {
return []grpc.DialOption{
grpc.WithDefaultCallOptions(
grpc.MaxCallSendMsgSize(MaxMsgSize),
grpc.MaxCallRecvMsgSize(MaxMsgSize),
),
}
}
func TracingInterceptorsDial(t opentracing.Tracer) []grpc.DialOption {
return []grpc.DialOption{
grpc.WithUnaryInterceptor(otgrpc.OpenTracingClientInterceptor(t)),
grpc.WithStreamInterceptor(otgrpc.OpenTracingStreamClientInterceptor(t)),
}
}
func MaxMsgServer() []grpc.ServerOption {
return []grpc.ServerOption{
grpc.MaxRecvMsgSize(MaxMsgSize),
grpc.MaxSendMsgSize(MaxMsgSize),
}
}
func TracingInterceptorsServer(t opentracing.Tracer) []grpc.ServerOption {
return []grpc.ServerOption{
grpc.UnaryInterceptor(otgrpc.OpenTracingServerInterceptor(t)),
grpc.StreamInterceptor(otgrpc.OpenTracingStreamServerInterceptor(t)),
}
}