Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { PortHTTP int PortGRPC int TLSConfig *TLSConfig GRPC *ConfigGRPC Checks []check.Check Endpoints []ServerEndpoint Version *appconf.V }
Config defines requirements for starting a server.
func DefaultConfig ¶ added in v0.2.34
DefaultConfig will construct the default configuration used by projects.
type ConfigGRPC ¶ added in v0.2.34
type ConfigGRPC struct {
ServerOptions []grpc.ServerOption
}
ConfigGRPC allows callers to provide custom options to the gRPC server.
type Server ¶ added in v0.2.34
type Server struct {
// contains filtered or unexported fields
}
Server manages the various servers, endpoints, and options used to handle traffic. It drastically simplifies setting up and tearing down two servers.
func NewServer ¶ added in v0.2.34
NewServer constructs a server given the provided configuration. By default, the server comes with the following:
- http server
- /health,/healthz endpoints
- /metrics endpoint
- /version endpoint
- prometheus metrics
- dual serve gRPC
- CORS
- H2C
- grpc server
- healthcheck service
- reflection service
- prometheus metrics
type ServerEndpoint ¶ added in v0.2.34
ServerEndpoint provides applications with ways to configure the underlying grpc and http servers.
func WithHealthEndpoint ¶ added in v0.2.34
func WithHealthEndpoint(checks ...check.Check) ServerEndpoint
WithHealthEndpoint sets up a server endpoint that responds to health requests.
func WithMetricsEndpoint ¶ added in v0.2.34
func WithMetricsEndpoint() ServerEndpoint
WithMetricsEndpoint sets up an endpoint that provides detailed metrics about the process.
func WithReflectionEndpoint ¶ added in v0.2.34
func WithReflectionEndpoint() ServerEndpoint
WithReflectionEndpoint configures the servers with a discovery service.
func WithVersionEndpoint ¶ added in v0.2.34
func WithVersionEndpoint(version *appconf.V) ServerEndpoint
WithVersionEndpoint sets up an endpoint that announces version metadata about the process.
type ServerOption ¶ added in v0.2.34
type ServerOption func(s *Server)
ServerOption provides a post-endpoint hook for configuring aspects about the server.
func WithCORS ¶ added in v0.2.34
func WithCORS() ServerOption
WithCORS configures the server to support CORS requests.
func WithDualServe ¶ added in v0.2.34
func WithDualServe() ServerOption
WithDualServe configures the HTTP server to handle both HTTP and gRPC requests.
func WithH2C ¶ added in v0.2.34
func WithH2C() ServerOption
WithH2C configures the server to respond to HTTP/2 plaintext requests.
func WithMetrics ¶ added in v0.2.34
func WithMetrics() ServerOption
WithMetrics enables reporting on standard HTTP metrics.