Skip to content

Commit 1778d41

Browse files
authored
Deprecate the server interceptor chain helpers (#423)
google.golang.org/grpc now implements the functionality directly.
1 parent 3d8607d commit 1778d41

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

chain.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
// Execution is done in left-to-right order, including passing of context.
1717
// For example ChainUnaryServer(one, two, three) will execute one before two before three, and three
1818
// will see context changes of one and two.
19+
//
20+
// While this can be useful in some scenarios, it is generally advisable to use google.golang.org/grpc.ChainUnaryInterceptor directly.
1921
func ChainUnaryServer(interceptors ...grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor {
2022
n := len(interceptors)
2123

@@ -40,6 +42,8 @@ func ChainUnaryServer(interceptors ...grpc.UnaryServerInterceptor) grpc.UnarySer
4042
// Execution is done in left-to-right order, including passing of context.
4143
// For example ChainUnaryServer(one, two, three) will execute one before two before three.
4244
// If you want to pass context between interceptors, use WrapServerStream.
45+
//
46+
// While this can be useful in some scenarios, it is generally advisable to use google.golang.org/grpc.ChainStreamInterceptor directly.
4347
func ChainStreamServer(interceptors ...grpc.StreamServerInterceptor) grpc.StreamServerInterceptor {
4448
n := len(interceptors)
4549

@@ -109,12 +113,16 @@ func ChainStreamClient(interceptors ...grpc.StreamClientInterceptor) grpc.Stream
109113
//
110114
// WithUnaryServerChain is a grpc.Server config option that accepts multiple unary interceptors.
111115
// Basically syntactic sugar.
116+
//
117+
// Deprecated: use google.golang.org/grpc.ChainUnaryInterceptor instead.
112118
func WithUnaryServerChain(interceptors ...grpc.UnaryServerInterceptor) grpc.ServerOption {
113-
return grpc.UnaryInterceptor(ChainUnaryServer(interceptors...))
119+
return grpc.ChainUnaryInterceptor(interceptors...)
114120
}
115121

116122
// WithStreamServerChain is a grpc.Server config option that accepts multiple stream interceptors.
117123
// Basically syntactic sugar.
124+
//
125+
// Deprecated: use google.golang.org/grpc.ChainStreamInterceptor instead.
118126
func WithStreamServerChain(interceptors ...grpc.StreamServerInterceptor) grpc.ServerOption {
119-
return grpc.StreamInterceptor(ChainStreamServer(interceptors...))
127+
return grpc.ChainStreamInterceptor(interceptors...)
120128
}

0 commit comments

Comments
 (0)