Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DNSReport ¶
type DNSReport struct { Enabled bool `json:"is_enabled,omitempty"` LocalQuery float64 `json:"local_query_ms,omitempty"` ExternalQuery float64 `json:"external_query_ms,omitempty"` Status `json:"status,omitempty"` }
DNSReport defines the health of the embeded DNS in this service by returning information on whether it is enabled, the duration of a local DNS query in milliseconds, the duration of an external DNS query in milliseconds and its derived status
type HTTPReport ¶
type HTTPReport struct { Query float64 `json:"query_ms,omitempty"` Status `json:"status,omitempty"` }
HTTPReport defines the health of the embeded HTTP API in this service by returning information on the duration of an API request in milliseconds and its derived status
type Report ¶
type Report struct { *StoreReport `json:"store,omitempty"` *DNSReport `json:"dns,omitempty"` *HTTPReport `json:"http,omitempty"` Status `json:"status,omitempty"` }
Report contains a full perspective of the app's health
Consists of a StoreReport, a DNSReport and a HTTPReport, as well as a general Status for the app
type Repository ¶
type Repository interface { // Store will take in the number of records in the store and the time.Duration for a // store.List operation, and return a StoreReport based off of this information Store(context.Context, int, time.Duration) *StoreReport // DNS will take in the address of the UDP server, the fallback DNS address (if set), // and a store.Record, which are used to answer internal and external DNS queries as part // of a health check; returning a DNSReport based off of this information DNS(ctx context.Context, address string, fallback string, records *store.Record) *DNSReport // HTTP will take the HTTP server's port so it can perform a HTTP request against one // of its endpoints, and returning a HTTPReport based off of this information HTTP(ctx context.Context, port int) *HTTPReport // Merge will unite a StoreReport, DNSReport and HTTPReport, returning a Report which // encapsulates these as well as an overall status for the service Merge(context.Context, *StoreReport, *DNSReport, *HTTPReport) *Report }
Repository defines the set of operations that a health checker should have
This will consist in basic operations to retrieve the status (and other metadata) from the running modules and services, while also being able to merge all of these individual reports into one
func WithTrace ¶
func WithTrace(r Repository) Repository
type Status ¶
type Status string
Status is a reserved type to list status types
This is not an enum as it is used so little, the cost of making it an int with converters was looking like too much clutter. It's only actually needed once and it does not seem that much of a long condition
const ( // Stopped shows that the service is not running Stopped Status = "stopped" // Unhealthy shows that the service is running, but presenting issues Unhealthy Status = "unhealthy" // Running shows that the service is generally running Running Status = "running" // Healthy shows that the service is running and responding to requests correctly Healthy Status = "healthy" )
type StoreReport ¶
type StoreReport struct { Len int `json:"num_items,omitempty"` Duration float64 `json:"query_ms,omitempty"` Status `json:"status,omitempty"` }
StoreReport defines the health of the embeded store in this service by returning information on the number of items, the duration it took to perform a store.List operation and its derived status