Documentation ¶
Overview ¶
Package service provides functionality common to services
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustRegister ¶
func MustRegister(registry *prometheus.Registry)
MustRegister will register all metrics on the given registry.
func SampleBuildInfo ¶
func SampleBuildInfo()
SampleBuildInfo creates a sample of the service_build_info metric. Since it is a gauge it needs to be set only once on the service startup.
Types ¶
type ShutdownHandler ¶
type ShutdownHandler struct {
// contains filtered or unexported fields
}
ShutdownHandler handles the shutdown of multiple services. It waits for a context to be cancelled to then call each service's Shutdown method.
func NewShutdownHandler ¶
func NewShutdownHandler(gracefulShutdownPeriod time.Duration) *ShutdownHandler
NewShutdownHandler creates a new ShutdownHandler with the given [gracefulShutdownPeriod].
func (*ShutdownHandler) Add ¶
func (s *ShutdownHandler) Add(service Shutdowner)
Add will add the given service to the handler. Must be called before ShutdownHandler.Wait is called.
func (*ShutdownHandler) Wait ¶
func (s *ShutdownHandler) Wait(ctx context.Context) error
Wait will wait for the given [ctx] to be cancelled. When [ctx] is cancelled it will shut down all services concurrently and wait for all of them to finish before returning. It will wait for each service to shut down for the wait period provided on NewShutdownHandler.
type Shutdowner ¶
Shutdowner represents a service that can shutdown.