heart

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2014 License: GPL-3.0-or-later Imports: 5 Imported by: 8

Documentation

Overview

Package heart provides a simple and generic heartbeat mechanism that oversees the pinging of some entities and reports various events through callbacks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback interface {
	Beat()
	Dead(id *big.Int)
}

Heartbeat callback interface to get notified of events.

type Heart

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

Heartbeat mechanism to monitor the liveliness of some entities.

func New

func New(beat time.Duration, kill int, handler Callback) *Heart

Creates and returns a new heartbeat mechanism beating once every beat, reporting entities as dead if not seen in kill beats.

func (*Heart) Monitor

func (h *Heart) Monitor(id *big.Int) error

Registers a new entity for the beater to monitor.

func (*Heart) Ping

func (h *Heart) Ping(id *big.Int) error

Updates the life tick of an entity.

func (*Heart) Start

func (h *Heart) Start()

Starts the beater and event notifier.

func (*Heart) Terminate

func (h *Heart) Terminate() error

Terminates the heartbeat mechanism.

func (*Heart) Unmonitor

func (h *Heart) Unmonitor(id *big.Int) error

Unregisters an entity from the possible balancing destinations.

Jump to

Keyboard shortcuts

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