diff --git a/zrpc/internal/chainclientinterceptors.go b/zrpc/internal/chainclientinterceptors.go deleted file mode 100644 index 9465e102..00000000 --- a/zrpc/internal/chainclientinterceptors.go +++ /dev/null @@ -1,13 +0,0 @@ -package internal - -import "google.golang.org/grpc" - -// WithStreamClientInterceptors uses given client stream interceptors. -func WithStreamClientInterceptors(interceptors ...grpc.StreamClientInterceptor) grpc.DialOption { - return grpc.WithChainStreamInterceptor(interceptors...) -} - -// WithUnaryClientInterceptors uses given client unary interceptors. -func WithUnaryClientInterceptors(interceptors ...grpc.UnaryClientInterceptor) grpc.DialOption { - return grpc.WithChainUnaryInterceptor(interceptors...) -} diff --git a/zrpc/internal/chainclientinterceptors_test.go b/zrpc/internal/chainclientinterceptors_test.go deleted file mode 100644 index 96fdc2ac..00000000 --- a/zrpc/internal/chainclientinterceptors_test.go +++ /dev/null @@ -1,17 +0,0 @@ -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestWithStreamClientInterceptors(t *testing.T) { - opts := WithStreamClientInterceptors() - assert.NotNil(t, opts) -} - -func TestWithUnaryClientInterceptors(t *testing.T) { - opts := WithUnaryClientInterceptors() - assert.NotNil(t, opts) -} diff --git a/zrpc/internal/chainserverinterceptors.go b/zrpc/internal/chainserverinterceptors.go deleted file mode 100644 index 4d67632e..00000000 --- a/zrpc/internal/chainserverinterceptors.go +++ /dev/null @@ -1,13 +0,0 @@ -package internal - -import "google.golang.org/grpc" - -// WithStreamServerInterceptors uses given server stream interceptors. -func WithStreamServerInterceptors(interceptors ...grpc.StreamServerInterceptor) grpc.ServerOption { - return grpc.ChainStreamInterceptor(interceptors...) -} - -// WithUnaryServerInterceptors uses given server unary interceptors. -func WithUnaryServerInterceptors(interceptors ...grpc.UnaryServerInterceptor) grpc.ServerOption { - return grpc.ChainUnaryInterceptor(interceptors...) -} diff --git a/zrpc/internal/chainserverinterceptors_test.go b/zrpc/internal/chainserverinterceptors_test.go deleted file mode 100644 index 127353ce..00000000 --- a/zrpc/internal/chainserverinterceptors_test.go +++ /dev/null @@ -1,17 +0,0 @@ -package internal - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestWithStreamServerInterceptors(t *testing.T) { - opts := WithStreamServerInterceptors() - assert.NotNil(t, opts) -} - -func TestWithUnaryServerInterceptors(t *testing.T) { - opts := WithUnaryServerInterceptors() - assert.NotNil(t, opts) -} diff --git a/zrpc/internal/client.go b/zrpc/internal/client.go index 72c38315..37de599a 100644 --- a/zrpc/internal/client.go +++ b/zrpc/internal/client.go @@ -76,7 +76,8 @@ func (c *client) buildDialOptions(opts ...ClientOption) []grpc.DialOption { var options []grpc.DialOption if !cliOpts.Secure { - options = append([]grpc.DialOption(nil), grpc.WithTransportCredentials(insecure.NewCredentials())) + options = append([]grpc.DialOption(nil), + grpc.WithTransportCredentials(insecure.NewCredentials())) } if !cliOpts.NonBlock { @@ -84,8 +85,8 @@ func (c *client) buildDialOptions(opts ...ClientOption) []grpc.DialOption { } options = append(options, - WithUnaryClientInterceptors(c.buildUnaryInterceptors(cliOpts.Timeout)...), - WithStreamClientInterceptors(c.buildStreamInterceptors()...), + grpc.WithChainUnaryInterceptor(c.buildUnaryInterceptors(cliOpts.Timeout)...), + grpc.WithChainStreamInterceptor(c.buildStreamInterceptors()...), ) return append(options, cliOpts.DialOptions...) @@ -162,7 +163,8 @@ func WithNonBlock() ClientOption { // WithStreamClientInterceptor returns a func to customize a ClientOptions with given interceptor. func WithStreamClientInterceptor(interceptor grpc.StreamClientInterceptor) ClientOption { return func(options *ClientOptions) { - options.DialOptions = append(options.DialOptions, WithStreamClientInterceptors(interceptor)) + options.DialOptions = append(options.DialOptions, + grpc.WithChainStreamInterceptor(interceptor)) } } @@ -184,6 +186,7 @@ func WithTransportCredentials(creds credentials.TransportCredentials) ClientOpti // WithUnaryClientInterceptor returns a func to customize a ClientOptions with given interceptor. func WithUnaryClientInterceptor(interceptor grpc.UnaryClientInterceptor) ClientOption { return func(options *ClientOptions) { - options.DialOptions = append(options.DialOptions, WithUnaryClientInterceptors(interceptor)) + options.DialOptions = append(options.DialOptions, + grpc.WithChainUnaryInterceptor(interceptor)) } } diff --git a/zrpc/internal/rpcserver.go b/zrpc/internal/rpcserver.go index 72d4c845..3cf8c4f1 100644 --- a/zrpc/internal/rpcserver.go +++ b/zrpc/internal/rpcserver.go @@ -63,8 +63,8 @@ func (s *rpcServer) Start(register RegisterFn) error { unaryInterceptors = append(unaryInterceptors, s.unaryInterceptors...) streamInterceptors := s.buildStreamInterceptors() streamInterceptors = append(streamInterceptors, s.streamInterceptors...) - options := append(s.options, WithUnaryServerInterceptors(unaryInterceptors...), - WithStreamServerInterceptors(streamInterceptors...)) + options := append(s.options, grpc.ChainUnaryInterceptor(unaryInterceptors...), + grpc.ChainStreamInterceptor(streamInterceptors...)) server := grpc.NewServer(options...) register(server)