monitor

package
v0.0.0-...-284234c Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

README

Monitor

type Monitor interface {
	NewHealthChecker(id, desc string, fn HealthCheck) HealthChecker
	Register(HealthChecker) error
	Deregister(HealthChecker) error
	HealthChecks() ([]HealthChecker, error)
	Start() error
	Stop() error
}

type HealthChecker interface {
	// Unique id of the healthcheck
	Id() string
	// Description of what the healthcheck does
	Description() string
	// Runs the the healthcheck
	Run() (map[string]string, error)
	// Returns the status of the last run
	// Better where the healthcheck is expensive to run
	Status() (map[string]string, error)
}

Supported

  • Platform
  • ?
  • ?

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HealthCheckTopic = "micro.monitor.healthcheck"
	StatusTopic      = "micro.monitor.status"
	StatsTopic       = "micro.monitor.stats"
)
View Source
var (
	ErrAlreadyExists = errors.New("already exists")
	ErrNotAvailable  = errors.New("not available")
)

Functions

func NewContext

func NewContext(ctx context.Context, c Monitor) context.Context

Types

type Checker

type Checker interface {
	NewHealthChecker(id, desc string, fn HealthCheck) HealthChecker
	Register(HealthChecker) error
	Deregister(HealthChecker) error
	HealthChecks() ([]HealthChecker, error)
}

Checker interface allows creation of healthchecks

type HealthCheck

type HealthCheck func() (map[string]string, error)

type HealthChecker

type HealthChecker interface {
	// Unique id of the healthcheck
	Id() string
	// Description of what the healthcheck does
	Description() string
	// Runs the the healthcheck
	Run() (map[string]string, error)
	// Returns the status of the last run
	// Better where the healthcheck is expensive to run
	Status() (map[string]string, error)
}

represents a healthcheck function

type Monitor

type Monitor interface {
	Checker
	Stats
	Start() error
	Stop() error
	String() string
}

The monitor aggregates, observes and publishes information about the current process. This includes status; started/running/stopped, stats; cpu, memory, runtime and healthchecks.

func FromContext

func FromContext(ctx context.Context) (Monitor, bool)

func NewMonitor

func NewMonitor(opts ...Option) Monitor

type Option

type Option func(*Options)

func Client

func Client(c client.Client) Option

func Interval

func Interval(i time.Duration) Option

func Server

func Server(s server.Server) Option

type Options

type Options struct {
	Interval time.Duration
	Client   client.Client
	Server   server.Server
}

type Request

type Request interface {
	Service() string
	Method() string
}

could be client or server request

type Stats

type Stats interface {
	RecordStat(r Request, d time.Duration, err error)
}

stats interface allows recording of endpoint stats

Directories

Path Synopsis
Package go_micro_platform_monitor is a generated protocol buffer package.
Package go_micro_platform_monitor is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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