servicestatus

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

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

Go to latest
Published: Oct 6, 2016 License: GPL-3.0 Imports: 6 Imported by: ? modules, 0 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

golang-service-status

Provides a JSON object exposing status information, ideal as part of a REST API for internal monitoring.

Installation

Import with something akin to:

import servicestatus "github.com/TheBookPeople/golang-service-status"

Usage

// Initialize
status := servicestatus.NewServiceStatus("app name", "0.0.1")

// Add service checks
status.AddCheck("Redis Ping", func() bool {
  // Perform the check here, return true if passed 
  return true
})

// Get a JSON string containing service info:
status.Status()

Format

As below. Checks are always part of the 'checks' array. If they have failed, they are included in 'errors' as well.

'Status' is either "online" or "offline".

{
  "name": "windows",
  "version": "3.11",
  "hostname": "clippy",
  "checks": [{
    "name": "redis",
    "description": "Can connect to Redis"
    "successful": true
  }],
  "errors": [],
  "timestamp": "2015-05-07 14:35:17",
  "uptime": "14d:23:11:21",
  "diskusage": "64%",
  "status": "online"
}

Contributing

  1. Fork it ( https://github.com/[my-github-username]/service-status/fork )
  2. git flow init -d (assuming you have git flow)
  3. Create your feature branch (git flow feature start my-new-feature)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin feature/my-new-feature)
  6. Create a new Pull Request

Copyright (c) 2015 The Book People

See LICENSE (GPLv3)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Successful  bool   `json:"successful"`
	// contains filtered or unexported fields
}

Check - to be performed when status info is requested.

type ServiceStatus

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

ServiceStatus - Provides status for service in TBP format.

func NewServiceStatus

func NewServiceStatus(name string, version string) ServiceStatus

NewServiceStatus - create a ServiceStatus

func (*ServiceStatus) AddCheck

func (ss *ServiceStatus) AddCheck(name string, description string, checkFunc func() bool)

AddCheck - register a check to be performed when status info is requested.

func (ServiceStatus) Status

func (ss ServiceStatus) Status() string

Status - returns a JSON status string

Jump to

Keyboard shortcuts

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