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

45 lines
858 B
Go
Raw Normal View History

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