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:
@@ -28,6 +28,13 @@ func TestServer_setupInterceptors(t *testing.T) {
|
||||
},
|
||||
CpuThreshold: 10,
|
||||
Timeout: 100,
|
||||
Middlewares: ServerMiddlewaresConf{
|
||||
Trace: true,
|
||||
Recover: true,
|
||||
Stat: true,
|
||||
Prometheus: true,
|
||||
Breaker: true,
|
||||
},
|
||||
}, new(stat.Metrics))
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 3, len(server.unaryInterceptors))
|
||||
@@ -51,11 +58,18 @@ func TestServer(t *testing.T) {
|
||||
StrictControl: false,
|
||||
Timeout: 0,
|
||||
CpuThreshold: 0,
|
||||
Middlewares: ServerMiddlewaresConf{
|
||||
Trace: true,
|
||||
Recover: true,
|
||||
Stat: true,
|
||||
Prometheus: true,
|
||||
Breaker: true,
|
||||
},
|
||||
}, func(server *grpc.Server) {
|
||||
})
|
||||
svr.AddOptions(grpc.ConnectionTimeout(time.Hour))
|
||||
svr.AddUnaryInterceptors(serverinterceptors.UnaryCrashInterceptor)
|
||||
svr.AddStreamInterceptors(serverinterceptors.StreamCrashInterceptor)
|
||||
svr.AddUnaryInterceptors(serverinterceptors.UnaryRecoverInterceptor)
|
||||
svr.AddStreamInterceptors(serverinterceptors.StreamRecoverInterceptor)
|
||||
go svr.Start()
|
||||
svr.Stop()
|
||||
}
|
||||
@@ -74,6 +88,13 @@ func TestServerError(t *testing.T) {
|
||||
},
|
||||
Auth: true,
|
||||
Redis: redis.RedisKeyConf{},
|
||||
Middlewares: ServerMiddlewaresConf{
|
||||
Trace: true,
|
||||
Recover: true,
|
||||
Stat: true,
|
||||
Prometheus: true,
|
||||
Breaker: true,
|
||||
},
|
||||
}, func(server *grpc.Server) {
|
||||
})
|
||||
assert.NotNil(t, err)
|
||||
@@ -93,11 +114,18 @@ func TestServer_HasEtcd(t *testing.T) {
|
||||
Key: "any",
|
||||
},
|
||||
Redis: redis.RedisKeyConf{},
|
||||
Middlewares: ServerMiddlewaresConf{
|
||||
Trace: true,
|
||||
Recover: true,
|
||||
Stat: true,
|
||||
Prometheus: true,
|
||||
Breaker: true,
|
||||
},
|
||||
}, func(server *grpc.Server) {
|
||||
})
|
||||
svr.AddOptions(grpc.ConnectionTimeout(time.Hour))
|
||||
svr.AddUnaryInterceptors(serverinterceptors.UnaryCrashInterceptor)
|
||||
svr.AddStreamInterceptors(serverinterceptors.StreamCrashInterceptor)
|
||||
svr.AddUnaryInterceptors(serverinterceptors.UnaryRecoverInterceptor)
|
||||
svr.AddStreamInterceptors(serverinterceptors.StreamRecoverInterceptor)
|
||||
go svr.Start()
|
||||
svr.Stop()
|
||||
}
|
||||
@@ -111,6 +139,13 @@ func TestServer_StartFailed(t *testing.T) {
|
||||
},
|
||||
},
|
||||
ListenOn: "localhost:aaa",
|
||||
Middlewares: ServerMiddlewaresConf{
|
||||
Trace: true,
|
||||
Recover: true,
|
||||
Stat: true,
|
||||
Prometheus: true,
|
||||
Breaker: true,
|
||||
},
|
||||
}, func(server *grpc.Server) {
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user