goose4

package module
v0.0.0-...-d71a5da Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2018 License: Apache-2.0 Imports: 10 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

goose4

import "github.com/zeebox/goose4"

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: "<a href="https://example.com/goose4_runbook.html">https://example.com/goose4_runbook.html</a>",
    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

Package files

config.go doc.go error.go goose4.go healthcheck.go status.go

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.

func (Config) Marshal
func (c Config) Marshal() (j []byte, err error)

Marshal returns a json document and, potentially, an error in order to respond with configuration for a service.

type Error

type Error struct {
    Status  int    `json:"status"`
    Message string `json:"message"`
}

Error is a simple placeholder to store non-2xx, non-3xx response data

func (Error) Marshal
func (e Error) Marshal() ([]byte, error)

Marshal wraps an Error in some json

type Goose4

type Goose4 struct {
    // contains filtered or unexported fields
}

Goose4 holds goose4 configuration and provides functions thereon

func NewGoose4
func NewGoose4(c Config) (g Goose4, err error)

NewGoose4 returns a Goose4 object to be used as net/http handler

func (*Goose4) AddTest
func (g *Goose4) AddTest(t Test)

AddTest updates a Goose4 test list for healthchecks. These tests are used to determine whether a service is up or not

func (Goose4) ServeHTTP
func (g Goose4) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is an http router to serve se4 endpoints

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
func (*Healthcheck) ASG
func (h *Healthcheck) ASG() (output []byte, errors bool, err error)

ASG runs critical tests

func (*Healthcheck) All
func (h *Healthcheck) All() (output []byte, errors bool, err error)

All runs all tests; both critical and non-critical

func (*Healthcheck) GTG
func (h *Healthcheck) GTG() (output []byte, errors bool, err error)

GTG runs non-critical tests: "Good to go"

type Status

type Status struct {
    Config
    System
}

Status embeds Config and System to give a concise system status

func (Status) Marshal
func (s Status) Marshal(boot time.Time) ([]byte, error)

Marshal returns a status doc based on passed in config and up-to-date system details

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

func NewSystem
func NewSystem(boot time.Time) System

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


Generated by godoc2md

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.

func (Config) Marshal

func (c Config) Marshal() (j []byte, err error)

Marshal returns a json document and, potentially, an error in order to respond with configuration for a service.

type Error

type Error struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
}

Error is a simple placeholder to store non-2xx, non-3xx response data

func (Error) Marshal

func (e Error) Marshal() ([]byte, error)

Marshal wraps an Error in some json

type Goose4

type Goose4 struct {
	// contains filtered or unexported fields
}

Goose4 holds goose4 configuration and provides functions thereon

func NewGoose4

func NewGoose4(c Config) (g Goose4, err error)

NewGoose4 returns a Goose4 object to be used as net/http handler

func (*Goose4) AddTest

func (g *Goose4) AddTest(t Test)

AddTest updates a Goose4 test list for healthchecks. These tests are used to determine whether a service is up or not

func (Goose4) ServeHTTP

func (g Goose4) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is an http router to serve se4 endpoints

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

func (*Healthcheck) All

func (h *Healthcheck) All() (output []byte, errors bool, err error)

All runs all tests; both RequiredByGTG and RequiredByASG options are ignored

func (*Healthcheck) GTG

func (h *Healthcheck) GTG() (output []byte, errors bool, err error)

GTG runs tests that have RequiredByGTG option enabled

type Status

type Status struct {
	Config
	System
}

Status embeds Config and System to give a concise system status

func (Status) Marshal

func (s Status) Marshal(boot time.Time) ([]byte, error)

Marshal returns a status doc based on passed in config and up-to-date system details

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

func NewSystem

func NewSystem(boot time.Time) System

NewSystem will generate a goose4.System and fill it with information taken from the system on which it is instantiated

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址