cbheartbeat

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

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

Go to latest
Published: Feb 20, 2017 License: Apache-2.0 Imports: 5 Imported by: 1

README

GoDoc

This provides a generic heartbeat mechanism for anything that needs to run in multiple nodes (machines, or even just in multiple processes on one machine) and nodes need to have a way to detect when other nodes have gone down, so that something can be done about it. That "something" is specified by the caller of this library.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HeartbeatChecker

type HeartbeatChecker interface {
	StartCheckingHeartbeats(staleThresholdMs int, handler HeartbeatsStoppedHandler) error
	StopCheckingHeartbeats()
}

A HeartbeatChecker checks _other_ nodes in the cluster for stale heartbeats and reacts by calling back the HeartbeatsStoppedHandler

type HeartbeatSender

type HeartbeatSender interface {
	StartSendingHeartbeats(intervalMs int) error
	StopSendingHeartbeats()
}

A HeartbeatSender sends heartbeats

type Heartbeater

type Heartbeater interface {
	HeartbeatChecker
	HeartbeatSender
}

A Heartbeater is something that can both send and check for heartbeats that are stored as documents in a Couchbase bucket

func NewCouchbaseHeartbeater

func NewCouchbaseHeartbeater(couchbaseUrl, bucketName, keyPrefix, nodeUuid string) (Heartbeater, error)

Create a new CouchbaseHeartbeater, passing in the arguments needed to connect to Couchbase Server (url, bucket), the keyPrefix which will be prepended to the heartbeat doc keys, and the nodeUuid, which is an opaque identifier for the "thing" that is using this library. You can think of nodeUuid as a generic token, so put whatever you want there as long as it is unique to the node where this is running. (eg, an ip address could work)

type HeartbeatsStoppedHandler

type HeartbeatsStoppedHandler interface {
	StaleHeartBeatDetected(nodeUuid string)
}

This is the callback interface that clients of this library need to pass in to be notified when other nodes have appeared to have stopped sending heartbeats.

Jump to

Keyboard shortcuts

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