mux

package
v0.3.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2021 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadTLSConfig

func LoadTLSConfig(cfg *TLSConfig) (*tls.Config, error)

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

func DefaultConfig(version *appconf.V) *Config

DefaultConfig will construct the default configuration used by projects.

func WithFlags added in v0.2.34

func WithFlags(cfg *Config) (*Config, []cli.Flag)

WithFlags sets up the appropriate CLI flags for the provided configuration.

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

func NewServer(cfg *Config) *Server

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

func (*Server) Serve added in v0.2.34

func (s *Server) Serve(root context.Context) error

Serve initializes and boots the server. If the server has already been initialized, it returns an error.

type ServerEndpoint added in v0.2.34

type ServerEndpoint func(ctx context.Context, grpcServer *grpc.Server, httpServer *http.ServeMux)

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.

type TLSConfig

type TLSConfig struct {
	CertPath string
	KeyPath  string
	CAPath   string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL