Documentation ¶
Overview ¶
Package heart implements a general purpose pacemaker.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Debug = func(v ...interface{}) {}
Debug is the default logger that Pacemaker uses.
View Source
var ErrDead = errors.New("no heartbeat replied")
Functions ¶
This section is empty.
Types ¶
type AtomicTime ¶
type AtomicTime struct {
// contains filtered or unexported fields
}
AtomicTime is a thread-safe UnixNano timestamp guarded by atomic.
func (*AtomicTime) Get ¶
func (t *AtomicTime) Get() int64
func (*AtomicTime) Set ¶
func (t *AtomicTime) Set(time time.Time)
func (*AtomicTime) Time ¶
func (t *AtomicTime) Time() time.Time
type Pacemaker ¶
type Pacemaker struct { // Heartrate is the received duration between heartbeats. Heartrate time.Duration // Time in nanoseconds, guarded by atomic read/writes. SentBeat AtomicTime EchoBeat AtomicTime // Any callback that returns an error will stop the pacer. Pace func() error // contains filtered or unexported fields }
func (*Pacemaker) StartAsync ¶
StartAsync starts the pacemaker asynchronously. The WaitGroup is optional.
Click to show internal directories.
Click to hide internal directories.