Repository: zeromicro/go-zero
Pull request #2768 (2023-01-08 16:41:24)

chore: remove simple methods, inlined

codecov-commenter: # [Codecov](https://codecov.io/gh/zeromicro/go-zero/pull/2768?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report
> Merging [#2768](https://codecov.io/gh/zeromicro/go-zero/pull/2768?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (2bf6c9a) into [master](https://codecov.io/gh/zeromicro/go-zero/commit/26c541b9cbd906af138795db349eebcca6a0dc8e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (26c541b) will **decrease** coverage by `0.00%`.
> The diff coverage is `100.00%`.


| [Impacted Files](https://codecov.io/gh/zeromicro/go-zero/pull/2768?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | |
|---|---|---|
| [zrpc/internal/client.go](https://codecov.io/gh/zeromicro/go-zero/pull/2768?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-enJwYy9pbnRlcm5hbC9jbGllbnQuZ28=) | `100.00% <100.00%> (ø)` | |
| [zrpc/internal/rpcserver.go](https://codecov.io/gh/zeromicro/go-zero/pull/2768?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-enJwYy9pbnRlcm5hbC9ycGNzZXJ2ZXIuZ28=) | `85.22% <100.00%> (ø)` | |


Patch:
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/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/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)
 


Test patch:
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_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)
-}