pubsubmon

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2019 License: Apache-2.0, MIT Imports: 17 Imported by: 0

Documentation

Overview

Package pubsubmon implements a PeerMonitor component for IPFS Cluster that uses PubSub to send and receive metrics.

Index

Constants

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

Default values for this Config.

Variables

View Source
var PubsubTopic = "monitor.metrics"

PubsubTopic specifies the topic used to publish Cluster metrics.

Functions

This section is empty.

Types

type Config

type Config struct {
	config.Saver

	CheckInterval time.Duration
}

Config allows to initialize a Monitor and customize some parameters.

func (*Config) ApplyEnvVars added in v0.10.0

func (cfg *Config) ApplyEnvVars() error

ApplyEnvVars fills in any Config fields found as environment variables.

func (*Config) ConfigKey

func (cfg *Config) ConfigKey() string

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

func (*Config) Default

func (cfg *Config) Default() error

Default sets the fields of this Config to sensible values.

func (*Config) LoadJSON

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

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

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

func (*Config) Validate

func (cfg *Config) Validate() error

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

type Monitor

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

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

func New

func New(h host.Host, cfg *Config) (*Monitor, error)

New creates a new PubSub monitor, using the given host and config.

func (*Monitor) Alerts

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

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

func (*Monitor) LatestMetrics

func (mon *Monitor) LatestMetrics(ctx context.Context, name string) []*api.Metric

LatestMetrics 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 peers.

func (*Monitor) LogMetric

func (mon *Monitor) LogMetric(ctx context.Context, m *api.Metric) error

LogMetric stores a metric so it can later be retrieved.

func (*Monitor) PublishMetric

func (mon *Monitor) PublishMetric(ctx context.Context, m *api.Metric) error

PublishMetric broadcasts a metric to all current cluster peers.

func (*Monitor) SetClient

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

SetClient saves the given rpc.Client for later use

func (*Monitor) Shutdown

func (mon *Monitor) Shutdown(ctx context.Context) 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