v0

package
v0.16.8 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultProxyCheckInterval = 5 * time.Second

	DefaultRequestTimeout          = 10 * time.Second
	DefaultSleepInterval           = 5 * time.Second
	DefaultKeeperFailInterval      = 20 * time.Second
	DefaultMaxStandbysPerSender    = 3
	DefaultSynchronousReplication  = false
	DefaultInitWithMultipleKeepers = false
	DefaultUsePGRewind             = false
)
View Source
const (
	CurrentCDFormatVersion uint64 = 0
)

Variables

This section is empty.

Functions

func BoolP

func BoolP(b bool) *bool

func MapStringP

func MapStringP(m map[string]string) *map[string]string

func StringP

func StringP(s string) *string

func UintP

func UintP(u uint) *uint

Types

type ClusterData

type ClusterData struct {
	// ClusterData format version. Used to detect incompatible
	// version and do upgrade. Needs to be bumped when a non
	// backward compatible change is done to the other struct
	// members.
	FormatVersion uint64

	KeepersState KeepersState
	ClusterView  *ClusterView
}

A struct containing the KeepersState and the ClusterView since they need to be in sync

type ClusterView

type ClusterView struct {
	Version     int
	Master      string
	KeepersRole KeepersRole
	ProxyConf   *ProxyConf
	Config      *NilConfig
	ChangeTime  time.Time
}

func NewClusterView

func NewClusterView() *ClusterView

NewClusterView return an initialized clusterView with Version: 0, zero ChangeTime, no Master and empty KeepersRole.

func (*ClusterView) Copy

func (cv *ClusterView) Copy() *ClusterView

func (*ClusterView) Equals

func (cv *ClusterView) Equals(ncv *ClusterView) bool

Equals checks if the clusterViews are the same. It ignores the ChangeTime.

func (*ClusterView) GetFollowersIDs

func (cv *ClusterView) GetFollowersIDs(id string) []string

Returns a sorted list of followersIDs

type Config

type Config struct {
	// Time after which any request (keepers checks from sentinel etc...) will fail.
	RequestTimeout time.Duration
	// Interval to wait before next check (for every component: keeper, sentinel, proxy).
	SleepInterval time.Duration
	// Interval after the first fail to declare a keeper as not healthy.
	KeeperFailInterval time.Duration
	// Max number of standbys for every sender. A sender can be a master or
	// another standby (with cascading replication).
	MaxStandbysPerSender uint
	// Use Synchronous replication between master and its standbys
	SynchronousReplication bool
	// Choose a random initial master when multiple keeper are registered
	InitWithMultipleKeepers bool
	// Whether to use pg_rewind
	UsePGRewind bool
	// Map of postgres parameters
	PGParameters map[string]string
}

func NewDefaultConfig

func NewDefaultConfig() *Config

func (*Config) Copy

func (c *Config) Copy() *Config

type Duration

type Duration struct {
	time.Duration
}

Duration is needed to be able to marshal/unmarshal json strings with time unit (eg. 3s, 100ms) instead of ugly times in nanoseconds.

func DurationP

func DurationP(d Duration) *Duration

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

type KeeperDiscoveryInfo

type KeeperDiscoveryInfo struct {
	ListenAddress string
	Port          string
}

type KeeperInfo

type KeeperInfo struct {
	ID                 string
	ClusterViewVersion int
	ListenAddress      string
	Port               string
	PGListenAddress    string
	PGPort             string
}

func (*KeeperInfo) Copy

func (k *KeeperInfo) Copy() *KeeperInfo

type KeeperRole

type KeeperRole struct {
	ID     string
	Follow string
}

func (*KeeperRole) Copy

func (kr *KeeperRole) Copy() *KeeperRole

type KeeperState

type KeeperState struct {
	ID                 string
	ErrorStartTime     time.Time
	Healthy            bool
	ClusterViewVersion int
	ListenAddress      string
	Port               string
	PGListenAddress    string
	PGPort             string
	PGState            *PostgresState
}

func (*KeeperState) ChangedFromKeeperInfo

func (ks *KeeperState) ChangedFromKeeperInfo(ki *KeeperInfo) (bool, error)

func (*KeeperState) CleanError

func (ks *KeeperState) CleanError()

func (*KeeperState) Copy

func (ks *KeeperState) Copy() *KeeperState

func (*KeeperState) SetError

func (ks *KeeperState) SetError()

func (*KeeperState) UpdateFromKeeperInfo

func (ks *KeeperState) UpdateFromKeeperInfo(ki *KeeperInfo) error

type KeepersDiscoveryInfo

type KeepersDiscoveryInfo []*KeeperDiscoveryInfo

type KeepersInfo

type KeepersInfo map[string]*KeeperInfo

type KeepersRole

type KeepersRole map[string]*KeeperRole

func NewKeepersRole

func NewKeepersRole() KeepersRole

func (KeepersRole) Add

func (ksr KeepersRole) Add(id string, follow string) error

func (KeepersRole) Copy

func (ksr KeepersRole) Copy() KeepersRole

type KeepersState

type KeepersState map[string]*KeeperState

func (KeepersState) Copy

func (kss KeepersState) Copy() KeepersState

func (KeepersState) NewFromKeeperInfo

func (kss KeepersState) NewFromKeeperInfo(ki *KeeperInfo) error

func (KeepersState) SortedKeys

func (kss KeepersState) SortedKeys() []string

type NilConfig

type NilConfig struct {
	RequestTimeout          *Duration          `json:"request_timeout,omitempty"`
	SleepInterval           *Duration          `json:"sleep_interval,omitempty"`
	KeeperFailInterval      *Duration          `json:"keeper_fail_interval,omitempty"`
	MaxStandbysPerSender    *uint              `json:"max_standbys_per_sender,omitempty"`
	SynchronousReplication  *bool              `json:"synchronous_replication,omitempty"`
	InitWithMultipleKeepers *bool              `json:"init_with_multiple_keepers,omitempty"`
	UsePGRewind             *bool              `json:"use_pg_rewind,omitempty"`
	PGParameters            *map[string]string `json:"pg_parameters,omitempty"`
}

func (*NilConfig) Copy

func (c *NilConfig) Copy() *NilConfig

func (*NilConfig) MergeDefaults

func (c *NilConfig) MergeDefaults()

func (*NilConfig) ToConfig

func (c *NilConfig) ToConfig() *Config

func (*NilConfig) UnmarshalJSON

func (c *NilConfig) UnmarshalJSON(in []byte) error

func (*NilConfig) Validate

func (c *NilConfig) Validate() error

type PostgresState

type PostgresState struct {
	Initialized      bool
	Role             common.Role
	SystemID         string
	TimelineID       uint64
	XLogPos          uint64
	TimelinesHistory PostgresTimelinesHistory
}

func (*PostgresState) Copy

func (p *PostgresState) Copy() *PostgresState

type PostgresTimelineHistory

type PostgresTimelineHistory struct {
	TimelineID  uint64
	SwitchPoint uint64
	Reason      string
}

type PostgresTimelinesHistory

type PostgresTimelinesHistory []*PostgresTimelineHistory

func (PostgresTimelinesHistory) Copy

func (PostgresTimelinesHistory) GetTimelineHistory

func (tlsh PostgresTimelinesHistory) GetTimelineHistory(id uint64) *PostgresTimelineHistory

type ProxiesInfo

type ProxiesInfo []*ProxyInfo

func (ProxiesInfo) Len

func (p ProxiesInfo) Len() int

func (ProxiesInfo) Less

func (p ProxiesInfo) Less(i, j int) bool

func (ProxiesInfo) Swap

func (p ProxiesInfo) Swap(i, j int)

type ProxyConf

type ProxyConf struct {
	Host string
	Port string
}

func (*ProxyConf) Copy

func (pc *ProxyConf) Copy() *ProxyConf

type ProxyInfo

type ProxyInfo struct {
	ID                 string
	ListenAddress      string
	Port               string
	ClusterViewVersion int
}

type SentinelInfo

type SentinelInfo struct {
	ID            string
	ListenAddress string
	Port          string
}

type SentinelsInfo

type SentinelsInfo []*SentinelInfo

func (SentinelsInfo) Len

func (s SentinelsInfo) Len() int

func (SentinelsInfo) Less

func (s SentinelsInfo) Less(i, j int) bool

func (SentinelsInfo) Swap

func (s SentinelsInfo) Swap(i, j int)

Jump to

Keyboard shortcuts

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