basic

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package basic implements a basic PeerMonitor component for IPFS Cluster. This component is in charge of logging metrics and triggering alerts when a peer goes down.

Index

Constants

View Source
const (
	DefaultCheckInterval = 15 * time.Second
)

Default values for this Config.

Variables

View Source
var AlertChannelCap = 256

AlertChannelCap specifies how much buffer the alerts channel has.

View Source
var WindowCap = 10

WindowCap specifies how many metrics to keep for given host and metric type

Functions

This section is empty.

Types

type Config added in v0.2.0

type Config struct {
	config.Saver

	CheckInterval time.Duration
}

Config allows to initialize a Monitor and customize some parameters.

func (*Config) ConfigKey added in v0.2.0

func (cfg *Config) ConfigKey() string

ConfigKey provides a human-friendly identifier for this type of Config.

func (*Config) Default added in v0.2.0

func (cfg *Config) Default() error

Default sets the fields of this Config to sensible values.

func (*Config) LoadJSON added in v0.2.0

func (cfg *Config) LoadJSON(raw []byte) error

LoadJSON sets the fields of this Config to the values defined by the JSON representation of it, as generated by ToJSON.

func (*Config) ToJSON added in v0.2.0

func (cfg *Config) ToJSON() ([]byte, error)

ToJSON generates a human-friendly JSON representation of this Config.

func (*Config) Validate added in v0.2.0

func (cfg *Config) Validate() error

Validate checks that the fields of this Config have working values, at least in appearance.

type Monitor added in v0.2.0

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

Monitor is a component in charge of monitoring peers, logging metrics and detecting failures

func NewMonitor added in v0.2.0

func NewMonitor(cfg *Config) (*Monitor, error)

NewMonitor creates a new monitor. It receives the window capacity (how many metrics to keep for each peer and type of metric) and the monitoringInterval (interval between the checks that produce alerts) as parameters

func (*Monitor) Alerts added in v0.2.0

func (mon *Monitor) Alerts() <-chan api.Alert

Alerts returns a channel on which alerts are sent when the monitor detects a failure.

func (*Monitor) LastMetrics added in v0.2.0

func (mon *Monitor) LastMetrics(name string) []api.Metric

LastMetrics returns last known VALID metrics of a given type. A metric is only valid if it has not expired and belongs to a current cluster peer.

func (*Monitor) LogMetric added in v0.2.0

func (mon *Monitor) LogMetric(m api.Metric)

LogMetric stores a metric so it can later be retrieved.

func (*Monitor) SetClient added in v0.2.0

func (mon *Monitor) SetClient(c *rpc.Client)

SetClient saves the given rpc.Client for later use

func (*Monitor) Shutdown added in v0.2.0

func (mon *Monitor) Shutdown() error

Shutdown stops the peer monitor. It particular, it will not deliver any alerts.

Jump to

Keyboard shortcuts

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