Documentation
¶
Index ¶
- func LoadFromEnv(config interface{}) error
- type Healther
- type Option
- func WithConsoleLogger(level zapcore.Level) Option
- func WithDevelopmentLogger() 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() Option
- func WithRouter(router *http.ServeMux) Option
- func WithStackdriverLogger(level zapcore.Level) 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 parses environment variables into a given struct and validates its fields' values.
Types ¶
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 ¶ added in v0.4.0
WithConsoleLogger is an option that uses a zap Logger with configurations set meant to be used for debugging in the console.
func WithDevelopmentLogger ¶
func WithDevelopmentLogger() Option
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.
func WithLogger ¶ added in v0.4.0
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 ¶
func WithProductionLogger() Option
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 ¶ added in v0.4.0
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 ¶ added in v0.5.0
WithTerminationWaitPeriod is an option that sets the termination wait period.
func WithZapMetrics ¶ added in v0.5.2
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) AddWorker ¶
AddWorker adds a named worker to the service. Added workers order is maintained.
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.