-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
45 lines (39 loc) · 986 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
package grpceptortest
import (
testpb "github.com/grpc-ecosystem/go-grpc-middleware/testing/testproto"
"google.golang.org/grpc"
)
type InterceptOption func(it *InterceptorTest) error
func InterceptOptsServerOptions(srvOpts []grpc.ServerOption) InterceptOption {
return func(it *InterceptorTest) error {
if srvOpts == nil {
return errNilServerOpts
}
it.ServerOpts = srvOpts
return nil
}
}
func InterceptOptsClientOptions(cliOpts []grpc.DialOption) InterceptOption {
return func(it *InterceptorTest) error {
if cliOpts == nil {
return errNilClientOpts
}
it.ClientOpts = cliOpts
return nil
}
}
func InterceptOptsTestServer(testServer testpb.TestServiceServer) InterceptOption {
return func(it *InterceptorTest) error {
if testServer == nil {
return errNilTestServer
}
it.TestService = testServer
return nil
}
}
func InterceptOptsUseTLS(tls bool) InterceptOption {
return func(it *InterceptorTest) error {
it.useTlS = tls
return nil
}
}