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

40 lines
795 B
Go
Raw Normal View History

2020-03-24 09:14:39 +00:00
package grpc
import (
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-25 10:17:38 +00:00
grpc_util "github.com/caos/zitadel/internal/api/grpc"
"github.com/caos/zitadel/internal/api/grpc/server/middleware"
2020-03-24 09:14:39 +00:00
)
var _ AuthServiceServer = (*Server)(nil)
type Server struct {
port string
searchLimit int
}
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
RegisterAuthServiceServer(gs, s)
return gs, nil
}