|
|
@ -1,10 +1,16 @@
|
|
|
|
package internal
|
|
|
|
package internal
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/stat"
|
|
|
|
"github.com/zeromicro/go-zero/core/stat"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
|
|
|
|
"google.golang.org/grpc/health"
|
|
|
|
|
|
|
|
"google.golang.org/grpc/keepalive"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const defaultConnectionIdleDuration = time.Minute * 5
|
|
|
|
|
|
|
|
|
|
|
|
type (
|
|
|
|
type (
|
|
|
|
// RegisterFn defines the method to register a server.
|
|
|
|
// RegisterFn defines the method to register a server.
|
|
|
|
RegisterFn func(*grpc.Server)
|
|
|
|
RegisterFn func(*grpc.Server)
|
|
|
@ -20,6 +26,7 @@ type (
|
|
|
|
|
|
|
|
|
|
|
|
baseRpcServer struct {
|
|
|
|
baseRpcServer struct {
|
|
|
|
address string
|
|
|
|
address string
|
|
|
|
|
|
|
|
health *health.Server
|
|
|
|
metrics *stat.Metrics
|
|
|
|
metrics *stat.Metrics
|
|
|
|
options []grpc.ServerOption
|
|
|
|
options []grpc.ServerOption
|
|
|
|
streamInterceptors []grpc.StreamServerInterceptor
|
|
|
|
streamInterceptors []grpc.StreamServerInterceptor
|
|
|
@ -30,7 +37,11 @@ type (
|
|
|
|
func newBaseRpcServer(address string, rpcServerOpts *rpcServerOptions) *baseRpcServer {
|
|
|
|
func newBaseRpcServer(address string, rpcServerOpts *rpcServerOptions) *baseRpcServer {
|
|
|
|
return &baseRpcServer{
|
|
|
|
return &baseRpcServer{
|
|
|
|
address: address,
|
|
|
|
address: address,
|
|
|
|
|
|
|
|
health: health.NewServer(),
|
|
|
|
metrics: rpcServerOpts.metrics,
|
|
|
|
metrics: rpcServerOpts.metrics,
|
|
|
|
|
|
|
|
options: []grpc.ServerOption{grpc.KeepaliveParams(keepalive.ServerParameters{
|
|
|
|
|
|
|
|
MaxConnectionIdle: defaultConnectionIdleDuration,
|
|
|
|
|
|
|
|
})},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|