service

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: MIT Imports: 6 Imported by: 0

README

Service

Our service module provides common functionality used accross services that are more high level/service specific.

Metrics

The library also provides common metrics for services.

service_build_info : gauge

This is an implemention of the idea documented here.

Labels:

  • revision : the revision identifier for the current commit or checkout.
  • goversion : Go's version used on the service.

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

type Shutdowner interface {
	Shutdown(context.Context) error
}

Shutdowner represents a service that can shutdown.

Jump to

Keyboard shortcuts

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