-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserver_options.go
146 lines (124 loc) · 4.67 KB
/
server_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//go:build !testcoverage
package grpcmock
import (
"time"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/keepalive"
"google.golang.org/grpc/stats"
"google.golang.org/grpc/tap"
)
// WriteBufferSize is a wrapper of google.golang.org/grpc.WriteBufferSize().
func WriteBufferSize(sz int) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.WriteBufferSize(sz))
}
}
// ReadBufferSize is a wrapper of google.golang.org/grpc.ReadBufferSize().
func ReadBufferSize(sz int) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.ReadBufferSize(sz))
}
}
// InitialWindowSize is a wrapper of google.golang.org/grpc.InitialWindowSize().
func InitialWindowSize(sz int32) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.InitialWindowSize(sz))
}
}
// InitialConnWindowSize is a wrapper of google.golang.org/grpc.InitialConnWindowSize().
func InitialConnWindowSize(sz int32) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.InitialConnWindowSize(sz))
}
}
// KeepaliveParams is a wrapper of google.golang.org/grpc.KeepaliveParams().
func KeepaliveParams(kp keepalive.ServerParameters) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.KeepaliveParams(kp))
}
}
// KeepaliveEnforcementPolicy is a wrapper of google.golang.org/grpc.KeepaliveEnforcementPolicy().
func KeepaliveEnforcementPolicy(kep keepalive.EnforcementPolicy) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.KeepaliveEnforcementPolicy(kep))
}
}
// MaxRecvMsgSize is a wrapper of google.golang.org/grpc.MaxRecvMsgSize().
func MaxRecvMsgSize(m int) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.MaxRecvMsgSize(m))
}
}
// MaxSendMsgSize is a wrapper of google.golang.org/grpc.MaxSendMsgSize().
func MaxSendMsgSize(m int) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.MaxSendMsgSize(m))
}
}
// MaxConcurrentStreams is a wrapper of google.golang.org/grpc.MaxConcurrentStreams().
func MaxConcurrentStreams(n uint32) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.MaxConcurrentStreams(n))
}
}
// Creds is a wrapper of google.golang.org/grpc.Creds().
func Creds(c credentials.TransportCredentials) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.Creds(c))
}
}
// UnaryInterceptor is a wrapper of google.golang.org/grpc.ChainUnaryInterceptor().
func UnaryInterceptor(i grpc.UnaryServerInterceptor) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.ChainUnaryInterceptor(i))
}
}
// ChainUnaryInterceptor is a wrapper of google.golang.org/grpc.ChainUnaryInterceptor().
func ChainUnaryInterceptor(interceptors ...grpc.UnaryServerInterceptor) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.ChainUnaryInterceptor(interceptors...))
}
}
// StreamInterceptor is a wrapper of google.golang.org/grpc.ChainStreamInterceptor().
func StreamInterceptor(i grpc.StreamServerInterceptor) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.ChainStreamInterceptor(i))
}
}
// ChainStreamInterceptor is a wrapper of google.golang.org/grpc.ChainStreamInterceptor().
func ChainStreamInterceptor(interceptors ...grpc.StreamServerInterceptor) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.ChainStreamInterceptor(interceptors...))
}
}
// InTapHandle is a wrapper of google.golang.org/grpc.InTapHandle().
func InTapHandle(h tap.ServerInHandle) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.InTapHandle(h))
}
}
// StatsHandler is a wrapper of google.golang.org/grpc.StatsHandler().
func StatsHandler(h stats.Handler) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.StatsHandler(h))
}
}
// UnknownServiceHandler is a wrapper of google.golang.org/grpc.UnknownServiceHandler().
func UnknownServiceHandler(streamHandler grpc.StreamHandler) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.UnknownServiceHandler(streamHandler))
}
}
// ConnectionTimeout is a wrapper of google.golang.org/grpc.ConnectionTimeout().
func ConnectionTimeout(d time.Duration) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.ConnectionTimeout(d))
}
}
// MaxHeaderListSize is a wrapper of google.golang.org/grpc.MaxHeaderListSize().
func MaxHeaderListSize(sz uint32) ServerOption {
return func(s *Server) {
s.serverOpts = append(s.serverOpts, grpc.MaxHeaderListSize(sz))
}
}