state

package
v0.0.0-...-b359386 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClusterFrozen   = errors.New("cluster is frozen")
	ErrDatabaseOffline = errors.New("database is offline")
	ErrPeerNotCaughtUp = errors.New("peer is not caught up")
)
View Source
var TimeNow = func() time.Time {
	return time.Now().UTC()
}

Functions

This section is empty.

Types

type Config

type Config struct {
	Role       Role                `json:"role"`
	Upstream   *discoverd.Instance `json:"upstream"`
	Downstream *discoverd.Instance `json:"downstream"`
	State      *State              `json:"state"`
}

func (*Config) Equal

func (x *Config) Equal(y *Config) bool

func (*Config) IsNewDownstream

func (x *Config) IsNewDownstream(y *Config) bool

type Database

type Database interface {
	XLogPosition() (xlog.Position, error)
	XLog() xlog.XLog
	Reconfigure(*Config) error
	Start() error
	Stop() error

	// Ready returns a channel that returns a single event when the interface
	// is ready.
	Ready() <-chan DatabaseEvent
}

type DatabaseEvent

type DatabaseEvent struct {
	Online bool
	Setup  bool
}

type Discoverd

type Discoverd interface {
	SetState(*DiscoverdState) error
	Events() <-chan *DiscoverdEvent
}

type DiscoverdEvent

type DiscoverdEvent struct {
	Kind  DiscoverdEventKind
	Peers []*discoverd.Instance
	State *DiscoverdState
}

type DiscoverdEventKind

type DiscoverdEventKind int
const (
	DiscoverdEventInit DiscoverdEventKind = iota
	DiscoverdEventState
	DiscoverdEventPeers
)

type DiscoverdState

type DiscoverdState struct {
	Index uint64 `json:"index"`
	State *State `json:"state"`
}

type FreezeDetails

type FreezeDetails struct {
	FrozenAt time.Time `json:"frozen_at"`
	Reason   string    `json:"reason"`
}

func NewFreezeDetails

func NewFreezeDetails(reason string) *FreezeDetails

type Peer

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

func NewPeer

func NewPeer(self *discoverd.Instance, id string, idKey string, singleton bool, d Discoverd, db Database, log log15.Logger) *Peer

func (*Peer) Close

func (p *Peer) Close() error

func (*Peer) Config

func (p *Peer) Config() *Config

func (*Peer) Info

func (p *Peer) Info() *PeerInfo

func (*Peer) Run

func (p *Peer) Run()

func (*Peer) SetDebugChannels

func (p *Peer) SetDebugChannels(restCh, retryCh chan struct{})

func (*Peer) Stop

func (p *Peer) Stop() error

type PeerInfo

type PeerInfo struct {
	ID           string                `json:"id"`
	Role         Role                  `json:"role"`
	RetryPending *time.Time            `json:"retry_pending,omitempty"`
	State        *State                `json:"state"`
	Peers        []*discoverd.Instance `json:"peers"`
}

type Role

type Role int
const (
	RoleUnknown Role = iota
	RolePrimary
	RoleSync
	RoleAsync
	RoleUnassigned
	RoleDeposed
	RoleNone
)

func (Role) MarshalJSON

func (r Role) MarshalJSON() ([]byte, error)

func (Role) String

func (r Role) String() string

func (*Role) UnmarshalJSON

func (r *Role) UnmarshalJSON(b []byte) error

type State

type State struct {
	Generation int                   `json:"generation"`
	Freeze     *FreezeDetails        `json:"freeze,omitempty"`
	Singleton  bool                  `json:"singleton,omitempty"`
	InitWAL    xlog.Position         `json:"init_wal"`
	Primary    *discoverd.Instance   `json:"primary"`
	Sync       *discoverd.Instance   `json:"sync"`
	Async      []*discoverd.Instance `json:"async"`
	Deposed    []*discoverd.Instance `json:"deposed,omitempty"`
}

func (*State) Clone

func (s *State) Clone() *State

func (*State) Equal

func (x *State) Equal(y *State) bool

Jump to

Keyboard shortcuts

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