Documentation
¶
Index ¶
- func ListenAndServe(runCtx context.Context, handler http.Handler, port string) <-chan struct{}
- func ListenAndServeGRPC(runCtx context.Context, grpcServer *grpc.Server, listenAddress string, ...) <-chan struct{}
- func ListenAndServeMetrics(runCtx context.Context, port string) <-chan struct{}
- func Main(serviceMain MainFunction, svcName string, options ...MainOption)
- func NewGRPCGatewayServer(server *grpc.Server, grpcPort, gatewayPort string, corsOptions cors.Options, ...) (*http.Server, error)
- func WithPathPrefixStrip(prefix string, h http.Handler) http.Handler
- type MainFunction
- type MainOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenAndServe ¶
ListenAndServe starts the server
func ListenAndServeGRPC ¶
func ListenAndServeGRPC(runCtx context.Context, grpcServer *grpc.Server, listenAddress string, gwServer *http.Server) <-chan struct{}
ListenAndServeGRPC starts both a GRPC server and a RESTful gateway server
func ListenAndServeMetrics ¶ added in v1.96.0
ListenAndServeMetrics serves the Prometheus metrics at /metrics on port until runCtx is canceled. The returned channel closes when the server has stopped.
Use a port that no Kubernetes service exposes, and let Prometheus scrape the pod through the prometheus.io/port annotation. Metrics on the application port are published with it by the ingress.
func Main ¶
func Main(serviceMain MainFunction, svcName string, options ...MainOption)
Main is a wrapper function over main - it handles the typical tasks like starting DB connection, handling OS signals, etc.
func NewGRPCGatewayServer ¶
func NewGRPCGatewayServer( server *grpc.Server, grpcPort, gatewayPort string, corsOptions cors.Options, handlerRegisterFunctions []func(context.Context, *runtime.ServeMux, *grpc.ClientConn) error, muxOptions ...runtime.ServeMuxOption, ) (*http.Server, error)
NewGRPCGatewayServer creates a gRPC-Gateway server with given grpc handler registration functions. It serves no metrics; use ListenAndServeMetrics to serve them on a separate port. muxOptions are passed to runtime.NewServeMux, e.g. runtime.WithIncomingHeaderMatcher to forward custom headers as gRPC metadata.
func WithPathPrefixStrip ¶ added in v1.92.0
WithPathPrefixStrip returns a handler that strips prefix from request URLs when they match the given path prefix (exact match or prefix + "/"). If prefix is empty or doesn't match, the original request is passed through unchanged.
Types ¶
type MainFunction ¶
type MainOption ¶
func WithPostgres ¶
func WithPostgres(opts *db.ConnectionOptions) MainOption