feat: add middlewares config for zrpc (#2766)

* feat: add middlewares config for zrpc

* chore: add tests

* chore: improve codecov

* chore: improve codecov
This commit is contained in:
Kevin Wan
2023-01-08 19:34:05 +08:00
committed by GitHub
parent ade6f9ee46
commit 26c541b9cb
13 changed files with 272 additions and 53 deletions

View File

@@ -70,7 +70,7 @@ func NewClient(c RpcClientConf, options ...ClientOption) (Client, error) {
return nil, err
}
client, err := internal.NewClient(target, opts...)
client, err := internal.NewClient(target, c.Middlewares, opts...)
if err != nil {
return nil, err
}
@@ -82,7 +82,14 @@ func NewClient(c RpcClientConf, options ...ClientOption) (Client, error) {
// NewClientWithTarget returns a Client with connecting to given target.
func NewClientWithTarget(target string, opts ...ClientOption) (Client, error) {
return internal.NewClient(target, opts...)
middlewares := ClientMiddlewaresConf{
Trace: true,
Duration: true,
Prometheus: true,
Breaker: true,
Timeout: true,
}
return internal.NewClient(target, middlewares, opts...)
}
// Conn returns the underlying grpc.ClientConn.