heartbeat

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const BLIP_TABLE_DDL = `` /* 266-byte string literal not displayed */

Variables

View Source
var InitErrorWait = 10 * time.Second

InitErrorWait is how long to wait between retries when initializing the heartbeat table (the first INSERT). This should be a relatively long wait.

View Source
var NoHeartbeatWait = 3 * time.Second
View Source
var ReadErrorWait = 1 * time.Second
View Source
var ReadOnlyWait = 20 * time.Second

ReadOnlyWait is how long to wait when MySQL is read-only (not writable). This should be a long wait because it could mean Blip is effectively in standby mode on a read-only replica until it's promoted to be the writable source, which might not happen for a very long time.

View Source
var ReadTimeout = 2 * time.Second
View Source
var ReplCheckWait = 3 * time.Second
View Source
var WriteTimeout = 5 * time.Second

WriteTimeout is how long to wait for MySQL to execute any heartbeat write. This should be much greater than the write frequency (config.hearbeat.freq) because it allows for slow network, MySQL, and so on.

Functions

This section is empty.

Types

type BlipReader

type BlipReader struct {
	*sync.Mutex
	// contains filtered or unexported fields
}

BlipReader reads heartbeats from BlipWriter.

func NewBlipReader

func NewBlipReader(args BlipReaderArgs) *BlipReader

func (*BlipReader) Lag

func (r *BlipReader) Lag(_ context.Context) (Lag, error)

func (*BlipReader) Start

func (r *BlipReader) Start() error

func (*BlipReader) Stop

func (r *BlipReader) Stop()

type BlipReaderArgs

type BlipReaderArgs struct {
	MonitorId  string
	DB         *sql.DB
	Table      string
	SourceId   string
	SourceRole string
	ReplCheck  string
	Waiter     LagWaiter
}

type Lag

type Lag struct {
	Milliseconds int64
	LastTs       time.Time
	SourceId     string
	SourceRole   string
	Replica      bool
}

type LagWaiter

type LagWaiter interface {
	Wait(now, past time.Time, freq int, srcId string) (int64, time.Duration)
}

type Reader

type Reader interface {
	Start() error
	Stop()
	Lag(context.Context) (Lag, error)
}

Reader reads heartbeats from a writer. It runs in a separate goroutine and reports replication lag for the repl.lag metric collector, where it's also created in Prepare. Currently, there's only one implementation: BlipReader, but an implementation for pt-table-heartbeat is an idea.

type SlowFastWaiter

type SlowFastWaiter struct {
	MonitorId      string
	NetworkLatency time.Duration
}

func (SlowFastWaiter) Wait

func (w SlowFastWaiter) Wait(now, last time.Time, freq int, srcId string) (int64, time.Duration)

type Writer

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

func NewWriter

func NewWriter(monitorId string, db *sql.DB, cfg blip.ConfigHeartbeat) *Writer

func (*Writer) Write

func (w *Writer) Write(stopChan, doneChan chan struct{}) error

Jump to

Keyboard shortcuts

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