Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 HTTPProvider ¶
HTTPProvider is an external service that checks the status of a HTTP endpoint
type MongoProvider ¶
MongoProvider is a status provider that uses mongo
type Providers ¶
type Providers struct {
HTTP StatusProvider
Mongo StatusProvider
Docker StatusProvider
}
Providers is a list of StatusProvider
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())