status

package
v0.0.2-rc-ci Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(service Service) func(next http.Handler) http.Handler

Middleware returns a new status middleware. It collects information about requests.

func Router

func Router(service Service) func(chi.Router)

Router returns a new status router.

Types

type RequestDuration

type RequestDuration struct {
	Min time.Duration `json:"min"`
	Max time.Duration `json:"max"`
	Avg time.Duration `json:"avg"`
}

RequestDuration tracks the duration of requests in different metrics.

type Service

type Service interface {
	// Status returns the current status of the server.
	Status() Status

	// RequestServed tells the service, that a request was served, with a given
	// request duration.
	RequestServed(duration time.Duration)
}

Service defines a a servies, that collects and provides status information about a server.

-go:generate go run github.com/petergtz/pegomock/pegomock generate eintopf.info/service/status Service --output=../../internal/mock/status_service.go --package=mock --mock-name=StatusService

func NewService

func NewService() Service

NewService returns a new status service.

type Status

type Status struct {
	Uptime          time.Duration   `json:"uptime"`
	Requests        uint            `json:"requests"`
	RequestDuration RequestDuration `json:"requestDuration"`
}

Status contains information about the status of a server.

Jump to

Keyboard shortcuts

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