zitadel/pkg/management/api/grpc/server.go

38 lines
782 B
Go
Raw Normal View History

2020-03-24 09:14:39 +00:00
package grpc
import (
2020-03-25 10:17:38 +00:00
grpc_util "github.com/caos/zitadel/internal/api/grpc"
2020-03-24 15:16:05 +00:00
"github.com/caos/zitadel/internal/api/grpc/server/middleware"
2020-03-24 10:20:45 +00:00
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
2020-03-24 09:14:39 +00:00
"google.golang.org/grpc"
)
var _ ManagementServiceServer = (*Server)(nil)
type Server struct {
2020-03-25 10:17:38 +00:00
port string
2020-03-24 09:14:39 +00:00
}
2020-03-30 15:51:25 +00:00
func StartServer(conf grpc_util.ServerConfig) *Server {
2020-03-24 09:14:39 +00:00
return &Server{
2020-03-25 10:17:38 +00:00
port: conf.Port,
2020-03-24 09:14:39 +00:00
}
}
func (s *Server) GRPCPort() string {
return s.port
}
func (s *Server) GRPCServer() (*grpc.Server, error) {
2020-03-24 10:20:45 +00:00
gs := grpc.NewServer(
2020-03-24 15:16:05 +00:00
middleware.TracingStatsServer("/Healthz", "/Ready", "/Validate"),
2020-03-24 10:20:45 +00:00
grpc.UnaryInterceptor(
grpc_middleware.ChainUnaryServer(
2020-03-24 15:16:05 +00:00
middleware.ErrorHandler(),
2020-03-24 10:20:45 +00:00
),
),
)
2020-03-24 09:14:39 +00:00
RegisterManagementServiceServer(gs, s)
return gs, nil
}