Documentation
¶
Overview ¶
Package status provides a simple, opinionated, kubernetes status http server.
Index ¶
Constants ¶
const ( DefaultPort = 8080 DefaultStartWait = time.Millisecond * 100 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Addresses indicates a list of addresses to Get
Addresses []string
// All, if set to true, will try to Get all addresses regardless of any errors
All bool
// UUIDs will be passed in via the query parameter
UUIDs []string
}
Client provides an interface to the server, for nested readiness checks, for example, providing short-circuiting logic, where the first failure status is returned
func (Client) Get ¶
Get hits the endpoint on all clients, and returns any statuses (if valid json responses are returned and can be deserialized), a non-nil error will be returned if any clients return a status not in the 200 range.
type Config ¶
type Config struct {
// Port is the tcp port to serve the http server
Port int
// Hostname is the hostname fragment for the http server, which defaults to an empty string (all)
Hostname string
// StartWait is how long the kubestatus.Service.Start operation will block after starting the server
StartWait time.Duration
// HealthHandler should return an error if the service is not ready
HealthHandler HealthHandler
// ReadinessHandler should return an error if the service is not ready
ReadinessHandler ReadinessHandler
// GinHandlers defines middleware to use
GinHandlers []gin.HandlerFunc
// Dependencies should be an array of addresses (including scheme) that are the root part of `/readiness`
// endpoints, note that the `uuids` query parameter will be set, appending configured service's UUID on the
// end of any existing `uuids` passed in with the original `/readiness` GET
Dependencies []string
// UUID may be set to override the UUID used for this service, a zero value will auto-generate.
UUID [16]byte
}
Config provides configuration of the status http server.
type FatalError ¶
FatalError models an error that occurred within the service, a non-nil Error would indicate that the server is stopped.
type HealthHandler ¶
type HealthHandler func() error
HealthHandler should return an error if the service is not ready
type ReadinessHandler ¶
type ReadinessHandler func() error
ReadinessHandler should return an error if the service is not ready
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is an instance of the status server
func NewService ¶
NewService constructs a new status.Service
func (*Service) Ctx ¶
Ctx return the service's context, which will cancel once the service has been started then stopped
func (*Service) Fatal ¶
func (s *Service) Fatal() FatalError
Fatal returns any fatal error that occurred within the service
func (*Service) Readiness ¶
Readiness returns the readiness of the service, taking any number of previous UUIDs (oldest first)
type Status ¶
type Status struct {
// Code is the HTTP status code
Code int `json:"code"`
// Message will be either 'OK', or the error message
Message string `json:"message"`
// Success will be bool set to false for anything but 200
Success bool `json:"success"`
// Started is a nanoseconds epoch indicating when the service was started
Started int64 `json:"started"`
// Uptime is a human readable string representation of the current timestamp - started
Uptime string `json:"uptime"`
// UUID is a per-process uuid value in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
UUID string `json:"uuid"`
}
Status is the response object returned by all endpoints