/
helper.go
36 lines (31 loc) · 1.25 KB
/
helper.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
package xconn
import (
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
"google.golang.org/grpc"
//"github.com/grpc-ecosystem/go-grpc-middleware"
"github.com/grpc-ecosystem/go-grpc-middleware/tags"
//"github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing"
"github.com/grpc-ecosystem/go-grpc-middleware/validator"
)
func AdditionalUnaryServerOptWithBase(item ...grpc.UnaryServerInterceptor) []grpc.UnaryServerInterceptor {
ret := []grpc.UnaryServerInterceptor{
grpc_validator.UnaryServerInterceptor(),
grpc_ctxtags.UnaryServerInterceptor(),
}
return append(ret, item...)
}
//AdditionalStreamServerOptWithBase add base
func AdditionalStreamServerOptWithBase(item ...grpc.StreamServerInterceptor) []grpc.StreamServerInterceptor {
ret := []grpc.StreamServerInterceptor{
grpc_validator.StreamServerInterceptor(),
grpc_ctxtags.StreamServerInterceptor(),
}
return append(ret, item...)
}
func CreateWithUnaryServerChain(item ...grpc.UnaryServerInterceptor) grpc.ServerOption {
return grpc_middleware.WithUnaryServerChain(item...)
}
//CreateWithStreamServerChain WithStreamServerChain
func CreateWithStreamServerChain(item ...grpc.StreamServerInterceptor) grpc.ServerOption {
return grpc_middleware.WithStreamServerChain(item...)
}