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 AtomicDuration ¶
type AtomicDuration struct {
// contains filtered or unexported fields
}
AtomicDuration is a thread-safe Duration guarded by atomic.
func (*AtomicDuration) Get ¶
func (d *AtomicDuration) Get() time.Duration
func (*AtomicDuration) Set ¶
func (d *AtomicDuration) Set(dura time.Duration)
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 AtomicDuration Ticks <-chan time.Time // Time in nanoseconds, guarded by atomic read/writes. SentBeat AtomicTime EchoBeat AtomicTime // Any callback that returns an error will stop the pacer. Pacer func(context.Context) error // contains filtered or unexported fields }
Pacemaker is the internal pacemaker state. All fields are not thread-safe unless they're atomic.
func NewPacemaker ¶
func (*Pacemaker) StopTicker ¶
func (p *Pacemaker) StopTicker()
Stop stops the pacemaker, or it does nothing if the pacemaker is not started.
Click to show internal directories.
Click to hide internal directories.