Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CertificateProvider ¶ added in v1.0.0
CertificateProvider is a status provider that check SSL certificate
type DayTemplate ¶ added in v1.5.0
type DayTemplate struct {
YYYYMMDD string
YYYYMMDD1 string // yesterday
YYYYMMDD2 string // -2 days
YYYYMMDD3 string // -3 days
YYYYMMDD4 string // -4 days
YYYYMMDD5 string // -5 days
YYYYMMDD6 string // -6 days
YYYYMMDD7 string // -7 days
NOW string // now time, with seconds precision
NOW1M string // now time -1m, with seconds precision
NOW5M string // now time -5m, with seconds precision
NOW10M string // now time -10m, with seconds precision
NOW15M string // now time -15m, with seconds precision
NOW30M string // now time -30m, with seconds precision
NOW1H string // now time -1h, with seconds precision
NOW5H string // now time -5h, with seconds precision
NOW12H string // now time -12h, with seconds precision
}
DayTemplate used to translate templates with date info
func NewDayTemplate ¶ added in v1.5.0
func NewDayTemplate(ts time.Time) *DayTemplate
NewDayTemplate makes day parser for given date ts - time to make template for
func (DayTemplate) Parse ¶ added in v1.5.0
func (d DayTemplate) Parse(dayTemplate string) string
Parse translate template to final string
type DockerProvider ¶
DockerProvider is a status provider that uses docker
func (*DockerProvider) Status ¶
func (d *DockerProvider) Status(req Request) (*Response, error)
Status the url looks like: docker:///var/run/docker.sock or docker://1.2.3.4:2375 optionally the url can contain a query param "required" with a comma separated list of required container names i.e. docker:///var/run/docker.sock?containers=foo,bar
type FileProvider ¶ added in v1.1.0
FileProvider is a status provider that checks the status of a file.
func (*FileProvider) Status ¶ added in v1.1.0
func (f *FileProvider) Status(req Request) (*Response, error)
Status returns the status of the file url looks like this: file://blah/foo.txt (relative path) or file:///blah/foo.txt (absolute path)
type HTTPProvider ¶
HTTPProvider is an external service that checks the status of a HTTP endpoint
type MongoProvider ¶
MongoProvider is a status provider that uses mongo
func (*MongoProvider) Status ¶
func (m *MongoProvider) Status(req Request) (*Response, error)
Status returns status of mongo, checks if connection established and ping is ok request URL looks like mongo:mongodb://172.17.42.1:27017/test?oplogMaxDelta=30m oplogMaxDelta is optional, if set, checks if oplog is not too far behind
type NginxProvider ¶ added in v0.5.0
NginxProvider is a status provider that uses nginx status response
func (*NginxProvider) Status ¶ added in v0.5.0
func (n *NginxProvider) Status(req Request) (*Response, error)
Status url looks like: nginx://example.com/nginx_status. It will try https first and if it fails http nginx response looks like this:
Active connections: 124 server accepts handled requests 783855 783855 1676992 Reading: 0 Writing: 300 Waiting: 27
type ProgramProvider ¶ added in v0.4.0
ProgramProvider is an external service that runs a command and checks the exit code.
type Providers ¶
type Providers struct {
HTTP StatusProvider
Mongo StatusProvider
Docker StatusProvider
Program StatusProvider
Nginx StatusProvider
Certificate StatusProvider
File StatusProvider
RMQ StatusProvider
}
Providers is a list of StatusProvider
type RMQProvider ¶ added in v1.3.0
RMQProvider is a status provider that uses RabbitMQ management API
func (*RMQProvider) Status ¶ added in v1.3.0
func (h *RMQProvider) Status(req Request) (*Response, error)
Status returns the status for a given queue via RabbitMQ management API Status url looks like: rmq://user:passwd@example.com:12345/queues/vhost/queue_name. It will try https first and if it fails http
type Response ¶
type Response struct {
Name string `json:"name"`
StatusCode int `json:"status_code"`
ResponseTime int64 `json:"response_time"` // milliseconds
Body map[string]interface{} `json:"body,omitempty"`
}
Response contains extended service information
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service wraps multiple StatusProvider and multiplex their Status() calls
func NewService ¶
NewService creates new external service supporting multiple providers reqs are requests to external services presented as pairs of name and url, i.e. health:http://localhost:8080/health
type StatusProvider ¶
StatusProvider is an interface for getting status from external services
type StatusProviderMock ¶
type StatusProviderMock struct {
// StatusFunc mocks the Status method.
StatusFunc func(req Request) (*Response, error)
// contains filtered or unexported fields
}
StatusProviderMock is a mock implementation of StatusProvider.
func TestSomethingThatUsesStatusProvider(t *testing.T) {
// make and configure a mocked StatusProvider
mockedStatusProvider := &StatusProviderMock{
StatusFunc: func(req Request) (*Response, error) {
panic("mock out the Status method")
},
}
// use mockedStatusProvider in code that requires StatusProvider
// and then make assertions.
}
func (*StatusProviderMock) Status ¶
func (mock *StatusProviderMock) Status(req Request) (*Response, error)
Status calls StatusFunc.
func (*StatusProviderMock) StatusCalls ¶
func (mock *StatusProviderMock) StatusCalls() []struct { Req Request }
StatusCalls gets all the calls that were made to Status. Check the length with:
len(mockedStatusProvider.StatusCalls())