Documentation
¶
Overview ¶
Package goose4 provides a golang implemenation of the se4 spec. It is a pure golang implementation with no/few extra dependencies.
It provides a `net/http` drop in HTTP Function which will route and provide bits of information.
Initialisation is reasonably simple:
import (
"net/http"
"github.com/zeebox/goose4"
)
c := goose4.Config{
ArtifactID: "some-artifact",
BuildNumber: "123",
BuildMachine: "localhost",
BuiltBy: "ci-user",
BuiltWhen: Time.now(),
CompilerVersion: "go version go1.7.4 darwin/amd64",
GitSha: "32b619ba997dfbfafd528ae3fea4e2cba8116be8",
RunbookURI: "https://example.com/goose4_runbook.html",
Version: "v0.0.1",
}
se4, err := goose4.NewGoose4(c)
Mounting se4 is just as easy:
http.Handle("/service/", se4)
panic(http.ListenAndServe(":80", nil))
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
ArtifactID string `json:"artifact_id"`
BuildNumber string `json:"build_number"`
BuildMachine string `json:"build_machine"`
BuiltBy string `json:"built_by"`
BuiltWhen time.Time `json:"built_when"`
CompilerVersion string `json:"compiler_version"`
GitSha string `json:"git_sha1"`
RunbookURI string `json:"runbook_uri"`
Version string `json:"version"`
}
Config implements a subset of https://github.com/beamly/SE4/blob/master/SE4.md#status and is used to configure static values for goose4.
type Goose4 ¶
type Goose4 struct {
// contains filtered or unexported fields
}
Goose4 holds goose4 configuration and provides functions thereon
type Healthcheck ¶
type Healthcheck struct {
ReportTime time.Time `json:"report_as_of"`
Duration string `json:"report_duration"`
Tests []Test `json:"tests"`
}
Healthcheck provides a full view of healthchecks and whether they fail or not
func NewHealthcheck ¶
func NewHealthcheck(t []Test) Healthcheck
NewHealthcheck creates a new Healthcheck
func (*Healthcheck) ASG ¶
func (h *Healthcheck) ASG() (output []byte, errors bool, err error)
ASG runs tests that have RequiredByASG option enabled
type System ¶
type System struct {
MachineName string `json:"machine_name"`
OSArch string `json:"os_arch"`
OSLoad string `json:"os_avgload"`
OSName string `json:"os_name"`
OSProcs string `json:"os_numprocessors"`
OSVersion string `json:"os_version"`
UpDuration string `json:"up_duration"`
UpSince string `json:"up_since"`
}
System contains system specific data for status responses
type Test ¶
type Test struct {
// A simple name to help identify tests from one another
// there is no enforcement of uniqueness- it is left to the developer
// to ensure these names make sense
Name string `json:"test_name"`
// RequiredForASG toggles whether the result of this Test is taken into account when checking ASG status
RequiredForASG bool `json:"-"`
// RequiredForGTG toggles whether the result of this Test is taken into account when checking GTG status
RequiredForGTG bool `json:"-"`
// F is a function which returns true for successful or false for a failure
F func() bool `json:"-"`
// The following are overwritten on whatsit
Result string `json:"test_result"`
Duration string `json:"duration_millis"`
TestTime time.Time `json:"tested_at"`
}
Test provides a way of having an API pass it's own healthcheck tests, https://github.com/beamly/SE4/blob/master/SE4.md#healthcheck) into goose4 to be run for the `/healthcheck/` endpoints. These are run in parallel and so tests which rely on one another/ sequentialness are not allowed