Documentation ¶
Index ¶
- func LoadFromEnv(config interface{}) error
- func LoadFromEnvWithParsers(config interface{}, parsers map[reflect.Type]env.ParserFunc) error
- type Aliver
- type Gatherer
- type Healther
- type Option
- func WithConsoleLogger(level zapcore.Level, opts ...zap.Option) Option
- func WithDevelopmentLogger(opts ...zap.Option) Option
- func WithHTTPServer(port string) Option
- func WithHealthz() Option
- func WithLogLevelHandlers() Option
- func WithLogger(logger *zap.Logger, atom zap.AtomicLevel) Option
- func WithMetrics() Option
- func WithMetricsHandler() Option
- func WithPProfHandlers() Option
- func WithProductionLogger(opts ...zap.Option) Option
- func WithRouter(router *http.ServeMux) Option
- func WithStackdriverLogger(level zapcore.Level, opts ...zap.Option) Option
- func WithTerminationGracePeriod(d time.Duration) Option
- func WithTerminationWaitPeriod(d time.Duration) Option
- func WithZapMetrics() Option
- type SVC
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadFromEnv ¶
func LoadFromEnv(config interface{}) error
LoadFromEnv is a shortcut for LoadFromEnvWithParsers with empty custom parsers.
func LoadFromEnvWithParsers ¶
LoadFromEnvWithParsers parses environment variables into a given struct and validates its fields' values, also allows for custom type parsers.
Types ¶
type Aliver ¶
type Aliver interface {
Alive() error
}
Aliver defines a worker that can report his livez status.
type Gatherer ¶
type Gatherer interface {
Gatherer() prometheus.Gatherer
}
Gatherer is a place for workers to return a prometheus.Gatherer for SVC to serve on the metrics endpoint.
type Healther ¶
type Healther interface {
Healthy() error
}
Healther defines a worker that can report his healthz status.
type Option ¶
Option defines SVC's option type.
func WithConsoleLogger ¶
WithConsoleLogger is an option that uses a zap Logger with configurations set meant to be used for debugging in the console.
func WithDevelopmentLogger ¶
WithDevelopmentLogger is an option that uses a zap Logger with configurations set meant to be used for development.
func WithHTTPServer ¶
WithHTTPServer is an option that adds an internal HTTP server exposing observability routes.
func WithHealthz ¶
func WithHealthz() Option
WithHealthz is an option that exposes Kubernetes conform Healthz HTTP routes.
func WithLogLevelHandlers ¶
func WithLogLevelHandlers() Option
WithLogLevelHandlers is an option that sets up HTTP routes to read write the log level. This option must be passed after other options that manipulate the logger to have any effect on that logger option.
func WithLogger ¶
func WithLogger(logger *zap.Logger, atom zap.AtomicLevel) Option
WithLogger is an option that allows you to provide your own customized logger.
func WithMetrics ¶
func WithMetrics() Option
WithMetrics is an option that exports metrics via prometheus.
func WithMetricsHandler ¶
func WithMetricsHandler() Option
WithMetricsHandler is an option that exposes Prometheus metrics for a Prometheus scraper.
func WithPProfHandlers ¶
func WithPProfHandlers() Option
WithPProfHandlers is an option that exposes Go's Performance Profiler via HTTP routes.
func WithProductionLogger ¶
WithProductionLogger is an option that uses a zap Logger with configurations set meant to be used for production.
func WithRouter ¶
WithRouter is an option that replaces the HTTP router with the given http router.
func WithStackdriverLogger ¶
WithStackdriverLogger is an option that uses a zap Logger with configurations set meant to be used for production and is compliant with the GCP/Stackdriver format.
func WithTerminationGracePeriod ¶
WithTerminationGracePeriod is an option that sets the termination grace period.
func WithTerminationWaitPeriod ¶
WithTerminationWaitPeriod is an option that sets the termination wait period.
func WithZapMetrics ¶
func WithZapMetrics() Option
WithZapMetrics will add a hook to the zap logger and emit metrics to prometheus based on log level and log name.
type SVC ¶
type SVC struct { Name string Version string Router *http.ServeMux TerminationGracePeriod time.Duration TerminationWaitPeriod time.Duration // contains filtered or unexported fields }
SVC defines the worker life-cycle manager. It holds service metadata, router, logger, and the workers.
func (*SVC) AddGatherer ¶
func (s *SVC) AddGatherer(gatherer prometheus.Gatherer)
func (*SVC) AddWorker ¶
AddWorker adds a named worker to the service. Added workers order is maintained.
func (*SVC) AddWorkerWithInitRetry ¶
AddWorkerWithInitRetry adds a named worker to the service. If the worker-initialization fails, it will be retried according to specified options.
func (*SVC) Run ¶
func (s *SVC) Run()
Run runs the service until either receiving an interrupt or a worker terminates.
func (*SVC) Shutdown ¶
func (s *SVC) Shutdown()
Shutdown signals the framework to terminate any already started workers and shutdown the service. The call is non-blocking. Terminating the workers comes with the guarantees as the `Run` method: All workers are given a total terminate grace-period until the service goes ahead completes the shutdown phase.