canary

package
v9.9.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alerter

type Alerter interface {
	NotUnhealthy(time.Time) error
	Unhealthy(time.Time) error
}

type Canary

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

func NewCanary

func NewCanary(
	sqlClient SQLClient,
	healthchecker Healthchecker,
	writeReadDelay time.Duration,
	logger lager.Logger,
) *Canary

func (*Canary) Chirp

func (c *Canary) Chirp(
	conns []*models.NamedConnection,
	writeConn *models.NamedConnection,
	timestamp time.Time,
) (bool, error)

Chirp returns (true,nil) when we know replication succeeded Chirp returns (false,nil) when we know know replication failed Chirp returns (false,error) when we cannot determine if replication succeeded Chirp will never return (true,error)

func (*Canary) Read

func (c *Canary) Read(conns []*models.NamedConnection, timestamp time.Time) (bool, error)

this function is exported for use in creating a write binary for exploring already tested in the Chirp functions test

func (*Canary) Setup

func (c *Canary) Setup(writeConn *models.NamedConnection) error

func (*Canary) Write

func (c *Canary) Write(timestamp time.Time, writeConn *models.NamedConnection) error

this function is exported for use in creating a write binary for exploring

type Chirper

type Chirper interface {
	Chirp(
		conns []*models.NamedConnection,
		writeConn *models.NamedConnection,
		timestamp time.Time,
	) (bool, error)
}

type CoalMiner

type CoalMiner struct {
	StateMachine StateMachine
	// contains filtered or unexported fields
}

func NewCoalMiner

func NewCoalMiner(
	connectionFactory ConnectionFactory,
	chirper Chirper,
	alerter Alerter,
	logger lager.Logger,
) *CoalMiner

func (*CoalMiner) LetSing

func (c *CoalMiner) LetSing(timer <-chan time.Time)

func (*CoalMiner) ParseReplicationHealth

func (c *CoalMiner) ParseReplicationHealth(ok bool, timestamp time.Time, err error)

Only exported for the purses of using in reader binary

type ConnectionFactory

type ConnectionFactory interface {
	Conns() ([]*models.NamedConnection, error)
	WriteConn() (*models.NamedConnection, error)
}

type Healthchecker

type Healthchecker interface {
	Healthy(*models.NamedConnection) (bool, error)
}

type SQLClient

type SQLClient interface {
	Setup(*sql.DB) error
	Write(*sql.DB, time.Time) error
	Check(*sql.DB, time.Time) (bool, error)
	Cleanup(*sql.DB) error
}

type State

type State int
const (
	NotUnhealthy State = iota
	Unhealthy
)

func (State) String

func (i State) String() string

type StateMachine

type StateMachine interface {
	BecomesUnhealthy(time.Time)
	BecomesNotUnhealthy(time.Time)
	RemainsInSameState(time.Time)
	GetState() State
}

type StatefulStateMachine

type StatefulStateMachine struct {
	State                 State
	OnBecomesUnhealthy    func(time.Time)
	OnBecomesNotUnhealthy func(time.Time)
	Logger                lager.Logger
}

func (*StatefulStateMachine) BecomesNotUnhealthy

func (m *StatefulStateMachine) BecomesNotUnhealthy(timestamp time.Time)

func (*StatefulStateMachine) BecomesUnhealthy

func (m *StatefulStateMachine) BecomesUnhealthy(timestamp time.Time)

func (*StatefulStateMachine) GetState

func (m *StatefulStateMachine) GetState() State

func (*StatefulStateMachine) RemainsInSameState

func (m *StatefulStateMachine) RemainsInSameState(timestamp time.Time)

type StatelessStateMachine

type StatelessStateMachine struct {
	OnBecomesUnhealthy    func(time.Time)
	OnBecomesNotUnhealthy func(time.Time)
}

func (StatelessStateMachine) BecomesNotUnhealthy

func (m StatelessStateMachine) BecomesNotUnhealthy(now time.Time)

func (StatelessStateMachine) BecomesUnhealthy

func (m StatelessStateMachine) BecomesUnhealthy(now time.Time)

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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