steward

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2017 License: MIT Imports: 2 Imported by: 2

README

Steward

Build Status Go Reportcard GoDoc License Release

Steward adds a drop in status endpoint with minimal effort for service health checks.

Requirements

Golang v1.6 or higher

Versioning

The project will be versioned in accordance with Semver 2.0.0. See the releases section for the latest version. Until version 1.0.0 the SDK is considered to be unstable.

License

See LICENSE.md for more information.

Documentation

Overview

Package steward provides a drop in way of adding a status endpoint to your services

Example (CustomResponse)

ExampleCustomResponse demonstrates how to configure a custom response

package main

import (
	"net"
	"net/http"

	. "github.com/gomicro/steward"
)

// StatusResponse is the data for the status endpoint to display
type StatusResponse struct {
	Application string `json:"app"`
	Version     string `json:"version"`
	BuildTime   string `json:"buildTime"`
}

// ExampleCustomResponse demonstrates how to configure a custom response
func main() {
	SetStatusResponse(&StatusResponse{Application: "Foo", Version: "1.0.0", BuildTime: "Today"})

	go http.ListenAndServe(net.JoinHostPort("0.0.0.0", "8000"), nil)
	select {}
}
Example (Dropin)

ExampleDropin demonstrates how to start a service with steward automatically injecting a status endpoint

package main

import (
	"net"
	"net/http"

	_ "github.com/gomicro/steward"
)

var (
	host = "0.0.0.0"
	port = "8000"
)

// ExampleDropin demonstrates how to start a service with steward automatically injecting a status endpoint
func main() {
	go http.ListenAndServe(net.JoinHostPort(host, port), nil)
	select {}
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleStatus

func HandleStatus(w http.ResponseWriter, req *http.Request)

HandleStatus implements the go http handler interface to display specified status details

func SetStatusEndpoint

func SetStatusEndpoint(e string)

SetStatusEndpoint overrides the default endpoint with desired value

func SetStatusResponse

func SetStatusResponse(v interface{})

SetStatusResponse overrides the default response payload for the status endpoint

Types

This section is empty.

Jump to

Keyboard shortcuts

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