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

44 lines
826 B
Go
Raw Normal View History

2020-03-24 06:09:28 +00:00
package grpc
import (
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"
2020-03-24 06:09:28 +00:00
)
var _ AdminServiceServer = (*Server)(nil)
type Config struct {
Port string
SearchLimit int
}
type Server struct {
port string
searchLimit int
}
func StartServer(conf Config) *Server {
return &Server{
port: conf.Port,
searchLimit: conf.SearchLimit,
}
}
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 06:09:28 +00:00
RegisterAdminServiceServer(gs, s)
return gs, nil
}