diff --git a/utils/grpc/runtime.go b/utils/grpc/runtime.go index 13a4db6..7d16597 100644 --- a/utils/grpc/runtime.go +++ b/utils/grpc/runtime.go @@ -30,6 +30,8 @@ type RuntimeServer struct { sharedpb.UnimplementedRuntimeServiceServer } +var Startime = time.Now() + //implementation of the shared helper function func (s *RuntimeServer) CheckRuntime(ctx context.Context, req *sharedpb.SignedRuntimeInfoRequest) (*sharedpb.RuntimeInfoReport, error) { //get connection object @@ -52,6 +54,7 @@ func (s *RuntimeServer) CheckRuntime(ctx context.Context, req *sharedpb.SignedRu res.Extra = []byte(nil) res.PeerId = []byte(nil) res.ServiceName = []byte(s.serviceName) + res.StartTime = Startime res.CurentTime = time.Now() res.GitHash = []byte(nil) res.Version = []byte(nil) diff --git a/utils/grpc/setup_server.go b/utils/grpc/setup_server.go index 8b02606..4784785 100644 --- a/utils/grpc/setup_server.go +++ b/utils/grpc/setup_server.go @@ -1,6 +1,7 @@ package grpc import ( + "fmt" "log" "net" @@ -36,15 +37,17 @@ func (s *GrpcServer) serverTypeToServerName(server interface{}) { case escrow.EscrowServiceServer: s.serverName = "escrow" case guard.GuardServiceServer: - s.serverName = "guard" + s.serverName = "guard-interceptor" case hub.HubQueryServiceServer: s.serverName = "hub" + case string: + s.serverName = fmt.Sprintf("%v", server) default: s.serverName = "unknown" } } -func (s *GrpcServer) GrpcServer(port string, dbURL string, rdURL string, server interface{}) *GrpcServer { +func (s *GrpcServer) GrpcServer(port string, dbURL string, rdURL string, server interface{}, options ...grpc.ServerOption) *GrpcServer { s.serverTypeToServerName(server) @@ -58,7 +61,7 @@ func (s *GrpcServer) GrpcServer(port string, dbURL string, rdURL string, server s.lis = lis - s.CreateServer(s.serverName). + s.CreateServer(s.serverName, options...). CreateHealthServer(). RegisterServer(server). RegisterHealthServer(). @@ -76,10 +79,11 @@ func (s *GrpcServer) AcceptConnection() *GrpcServer { return s } -func (s *GrpcServer) CreateServer(serverName string) *GrpcServer { +func (s *GrpcServer) CreateServer(serverName string, options ...grpc.ServerOption) *GrpcServer { //create grpc server s.serverName = serverName - s.server = grpc.NewServer(middleware.GrpcServerOption) + options = append(options, middleware.GrpcServerOption) + s.server = grpc.NewServer(options...) return s }