Documentation
¶
Index ¶
- Constants
- func BoolP(b bool) *bool
- func Uint16P(u uint16) *uint16
- func Uint32P(u uint32) *uint32
- type ArchiveRecoverySettings
- type Cluster
- type ClusterData
- type ClusterInitMode
- type ClusterPhase
- type ClusterRole
- type ClusterSpec
- type ClusterStatus
- type DB
- type DBInitMode
- type DBSpec
- type DBStatus
- type DBs
- type Duration
- type ExistingConfig
- type FollowConfig
- type FollowType
- type Keeper
- type KeeperInfo
- type KeeperSpec
- type KeeperStatus
- type Keepers
- type KeepersInfo
- type NewConfig
- type PGParameters
- type PITRConfig
- type PostgresState
- type PostgresTimelineHistory
- type PostgresTimelinesHistory
- type ProxiesInfo
- type ProxiesInfoSlice
- type Proxy
- type ProxyInfo
- type ProxySpec
- type ProxyStatus
- type RecoveryTargetSettings
- type SUReplAccessMode
- type SentinelInfo
- type SentinelsInfo
- type StandbySettings
Constants ¶
const ( DefaultStoreTimeout = 5 * time.Second DefaultProxyCheckInterval = 5 * time.Second DefaultProxyTimeoutInterval = 15 * time.Second DefaultDBWaitReadyTimeout = 60 * time.Second DefaultDBNotIncreasingXLogPosTimes = 10 DefaultSleepInterval = 5 * time.Second DefaultRequestTimeout = 10 * time.Second DefaultConvergenceTimeout = 30 * time.Second DefaultInitTimeout = 5 * time.Minute DefaultSyncTimeout = 30 * time.Minute DefaultFailInterval = 20 * time.Second DefaultDeadKeeperRemovalInterval = 48 * time.Hour DefaultMaxStandbys uint16 = 20 DefaultMaxStandbysPerSender uint16 = 3 DefaultMaxStandbyLag = 1024 * 1204 DefaultSynchronousReplication = false DefaultMinSynchronousStandbys uint16 = 1 DefaultMaxSynchronousStandbys uint16 = 1 DefaultAdditionalWalSenders = 5 DefaultUsePgrewind = false DefaultMergePGParameter = true DefaultRole ClusterRole = ClusterRoleMaster DefaultSUReplAccess SUReplAccessMode = SUReplAccessAll )
const ( NoGeneration int64 = 0 InitialGeneration int64 = 1 )
const (
CurrentCDFormatVersion uint64 = 1
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArchiveRecoverySettings ¶ added in v0.5.0
type ArchiveRecoverySettings struct { // value for restore_command RestoreCommand string `json:"restoreCommand,omitempty"` }
ArchiveRecoverySettings defines the archive recovery settings in the recovery.conf file (https://www.postgresql.org/docs/9.6/static/archive-recovery-settings.html )
type Cluster ¶ added in v0.5.0
type Cluster struct { UID string `json:"uid,omitempty"` Generation int64 `json:"generation,omitempty"` ChangeTime time.Time `json:"changeTime,omitempty"` Spec *ClusterSpec `json:"spec,omitempty"` Status ClusterStatus `json:"status,omitempty"` }
func NewCluster ¶ added in v0.5.0
func NewCluster(uid string, cs *ClusterSpec) *Cluster
func (*Cluster) DefSpec ¶ added in v0.5.0
func (c *Cluster) DefSpec() *ClusterSpec
DefSpec returns a new ClusterSpec with unspecified values populated with their defaults
func (*Cluster) UpdateSpec ¶ added in v0.5.0
func (c *Cluster) UpdateSpec(ns *ClusterSpec) error
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 Cluster *Cluster Keepers Keepers DBs DBs Proxy *Proxy }
for simplicity keep all the changes to the various components atomic (using an unique key)
func NewClusterData ¶ added in v0.5.0
func NewClusterData(c *Cluster) *ClusterData
func (*ClusterData) DeepCopy ¶ added in v0.5.0
func (c *ClusterData) DeepCopy() *ClusterData
func (*ClusterData) FindDB ¶ added in v0.5.0
func (cd *ClusterData) FindDB(keeper *Keeper) *DB
type ClusterInitMode ¶ added in v0.5.0
type ClusterInitMode string
const ( // Initialize a cluster starting from a freshly initialized database cluster. Valid only when cluster role is master. ClusterInitModeNew ClusterInitMode = "new" // Initialize a cluster doing a point in time recovery on a keeper. ClusterInitModePITR ClusterInitMode = "pitr" // Initialize a cluster with an user specified already populated db cluster. ClusterInitModeExisting ClusterInitMode = "existing" )
func ClusterInitModeP ¶ added in v0.5.0
func ClusterInitModeP(s ClusterInitMode) *ClusterInitMode
type ClusterPhase ¶ added in v0.5.0
type ClusterPhase string
const ( ClusterPhaseInitializing ClusterPhase = "initializing" ClusterPhaseNormal ClusterPhase = "normal" )
type ClusterRole ¶ added in v0.5.0
type ClusterRole string
const ( ClusterRoleMaster ClusterRole = "master" ClusterRoleStandby ClusterRole = "standby" )
func ClusterRoleP ¶ added in v0.6.0
func ClusterRoleP(s ClusterRole) *ClusterRole
type ClusterSpec ¶ added in v0.5.0
type ClusterSpec struct { // Interval to wait before next check SleepInterval *Duration `json:"sleepInterval,omitempty"` // Time after which any request (keepers checks from sentinel etc...) will fail. RequestTimeout *Duration `json:"requestTimeout,omitempty"` // Interval to wait for a db to be converged to the required state when // no long operation are expected. ConvergenceTimeout *Duration `json:"convergenceTimeout,omitempty"` // Interval to wait for a db to be initialized (doing a initdb) InitTimeout *Duration `json:"initTimeout,omitempty"` // Interval to wait for a db to be synced with a master SyncTimeout *Duration `json:"syncTimeout,omitempty"` // Interval after the first fail to declare a keeper or a db as not healthy. FailInterval *Duration `json:"failInterval,omitempty"` // Interval after which a dead keeper will be removed from the cluster data DeadKeeperRemovalInterval *Duration `json:"deadKeeperRemovalInterval,omitempty"` // Max number of standbys. This needs to be greater enough to cover both // standby managed by stolon and additional standbys configured by the // user. Its value affect different postgres parameters like // max_replication_slots and max_wal_senders. Setting this to a number // lower than the sum of stolon managed standbys and user managed // standbys will have unpredicatable effects due to problems creating // replication slots or replication problems due to exhausted wal // senders. MaxStandbys *uint16 `json:"maxStandbys,omitempty"` // Max number of standbys for every sender. A sender can be a master or // another standby (if/when implementing cascading replication). MaxStandbysPerSender *uint16 `json:"maxStandbysPerSender,omitempty"` // Max lag in bytes that an asynchronous standy can have to be elected in // place of a failed master MaxStandbyLag *uint32 `json:"maxStandbyLag,omitempty"` // Use Synchronous replication between master and its standbys SynchronousReplication *bool `json:"synchronousReplication,omitempty"` // MinSynchronousStandbys is the mininum number if synchronous standbys // to be configured when SynchronousReplication is true MinSynchronousStandbys *uint16 `json:"minSynchronousStandbys,omitempty"` // MaxSynchronousStandbys is the maximum number if synchronous standbys // to be configured when SynchronousReplication is true MaxSynchronousStandbys *uint16 `json:"maxSynchronousStandbys,omitempty"` // AdditionalWalSenders defines the number of additional wal_senders in // addition to the ones internally defined by stolon AdditionalWalSenders *uint16 `json:"additionalWalSenders"` // AdditionalMasterReplicationSlots defines additional replication slots to // be created on the master postgres instance. Replication slots not defined // here will be dropped from the master instance (i.e. manually created // replication slots will be removed). AdditionalMasterReplicationSlots []string `json:"additionalMasterReplicationSlots"` // Whether to use pg_rewind UsePgrewind *bool `json:"usePgrewind,omitempty"` // InitMode defines the cluster initialization mode. Current modes are: new, existing, pitr InitMode *ClusterInitMode `json:"initMode,omitempty"` // Whether to merge pgParameters of the initialized db cluster, useful // the retain initdb generated parameters when InitMode is new, retain // current parameters when initMode is existing or pitr. MergePgParameters *bool `json:"mergePgParameters,omitempty"` // Role defines the cluster operating role (master or standby of an external database) Role *ClusterRole `json:"role,omitempty"` // Init configuration used when InitMode is "new" NewConfig *NewConfig `json:"newConfig,omitempty"` // Point in time recovery init configuration used when InitMode is "pitr" PITRConfig *PITRConfig `json:"pitrConfig,omitempty"` // Existing init configuration used when InitMode is "existing" ExistingConfig *ExistingConfig `json:"existingConfig,omitempty"` // Standby setting when role is standby StandbySettings *StandbySettings `json:"standbySettings,omitempty"` // Define the mode of the default hba rules needed for replication by standby keepers (the su and repl auth methods will be the one provided in the keeper command line options) // Values can be "all" or "strict", "all" allow access from all ips, "strict" restrict master access to standby servers ips. // Default is "all" DefaultSUReplAccessMode *SUReplAccessMode `json:"defaultSUReplAccessMode,omitempty"` // Map of postgres parameters PGParameters PGParameters `json:"pgParameters,omitempty"` // Additional pg_hba.conf entries // we don't set omitempty since we want to distinguish between null or empty slice PGHBA []string `json:"pgHBA"` }
func (*ClusterSpec) DeepCopy ¶ added in v0.5.0
func (c *ClusterSpec) DeepCopy() *ClusterSpec
func (*ClusterSpec) Validate ¶ added in v0.5.0
func (os *ClusterSpec) Validate() error
Validate validates a cluster spec.
func (*ClusterSpec) WithDefaults ¶ added in v0.5.0
func (os *ClusterSpec) WithDefaults() *ClusterSpec
WithDefaults returns a new ClusterSpec with unspecified values populated with their defaults
type ClusterStatus ¶ added in v0.5.0
type ClusterStatus struct { CurrentGeneration int64 `json:"currentGeneration,omitempty"` Phase ClusterPhase `json:"phase,omitempty"` // Master DB UID Master string `json:"master,omitempty"` }
type DBInitMode ¶ added in v0.5.0
type DBInitMode string
const ( DBInitModeNone DBInitMode = "none" // Use existing db cluster data DBInitModeExisting DBInitMode = "existing" // Initialize a db starting from a freshly initialized database cluster DBInitModeNew DBInitMode = "new" // Initialize a db doing a point in time recovery DBInitModePITR DBInitMode = "pitr" // Initialize a db doing a resync to a target database cluster DBInitModeResync DBInitMode = "resync" )
type DBSpec ¶ added in v0.5.0
type DBSpec struct { // The KeeperUID this db is assigned to KeeperUID string `json:"keeperUID,omitempty"` // Time after which any request (keepers checks from sentinel etc...) will fail. RequestTimeout Duration `json:"requestTimeout,omitempty"` // See ClusterSpec MaxStandbys description MaxStandbys uint16 `json:"maxStandbys,omitempty"` // Use Synchronous replication between master and its standbys SynchronousReplication bool `json:"synchronousReplication,omitempty"` // Whether to use pg_rewind UsePgrewind bool `json:"usePgrewind,omitempty"` // AdditionalWalSenders defines the number of additional wal_senders in // addition to the ones internally defined by stolon AdditionalWalSenders uint16 `json:"additionalWalSenders"` // AdditionalReplicationSlots is a list of additional replication slots. // Replication slots not defined here will be dropped from the instance // (i.e. manually created replication slots will be removed). AdditionalReplicationSlots []string `json:"additionalReplicationSlots"` // InitMode defines the db initialization mode. Current modes are: none, new InitMode DBInitMode `json:"initMode,omitempty"` // Init configuration used when InitMode is "new" NewConfig *NewConfig `json:"newConfig,omitempty"` // Point in time recovery init configuration used when InitMode is "pitr" PITRConfig *PITRConfig `json:"pitrConfig,omitempty"` // Map of postgres parameters PGParameters PGParameters `json:"pgParameters,omitempty"` // Additional pg_hba.conf entries // We don't set omitempty since we want to distinguish between null or empty slice PGHBA []string `json:"pgHBA"` // DB Role (master or standby) Role common.Role `json:"role,omitempty"` // FollowConfig when Role is "standby" FollowConfig *FollowConfig `json:"followConfig,omitempty"` // Followers DB UIDs Followers []string `json:"followers"` // Whether to include previous postgresql.conf IncludeConfig bool `json:"includePreviousConfig,omitempty"` // SynchronousStandbys are the standbys to be configured as synchronous SynchronousStandbys []string `json:"synchronousStandbys"` // External SynchronousStandbys are external standbys names to be configured as synchronous ExternalSynchronousStandbys []string `json:"externalSynchronousStandbys"` }
type DBStatus ¶ added in v0.5.0
type DBStatus struct { Healthy bool `json:"healthy,omitempty"` CurrentGeneration int64 `json:"currentGeneration,omitempty"` ListenAddress string `json:"listenAddress,omitempty"` Port string `json:"port,omitempty"` SystemID string `json:"systemdID,omitempty"` TimelineID uint64 `json:"timelineID,omitempty"` XLogPos uint64 `json:"xLogPos,omitempty"` TimelinesHistory PostgresTimelinesHistory `json:"timelinesHistory,omitempty"` PGParameters PGParameters `json:"pgParameters,omitempty"` // DBUIDs of the internal standbys set as synchronous // NOTE(sgotti) we currently don't report the external synchronous standbys. // If/when needed lets add a new ExternalSynchronousStandbys field SynchronousStandbys []string `json:"synchronousStandbys"` OlderWalFile string `json:"olderWalFile,omitempty"` }
type 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 (Duration) MarshalJSON ¶
func (*Duration) UnmarshalJSON ¶
type ExistingConfig ¶ added in v0.5.0
type ExistingConfig struct {
KeeperUID string `json:"keeperUID,omitempty"`
}
type FollowConfig ¶ added in v0.5.0
type FollowConfig struct { Type FollowType `json:"type,omitempty"` // Keeper ID to follow when Type is "internal" DBUID string `json:"dbuid,omitempty"` // Standby settings when Type is "external" StandbySettings *StandbySettings `json:"standbySettings,omitempty"` }
type FollowType ¶ added in v0.5.0
type FollowType string
const ( // Follow an db managed by a keeper in our cluster FollowTypeInternal FollowType = "internal" // Follow an external db FollowTypeExternal FollowType = "external" )
type Keeper ¶
type Keeper struct { // Keeper ID UID string `json:"uid,omitempty"` Generation int64 `json:"generation,omitempty"` ChangeTime time.Time `json:"changeTime,omitempty"` Spec *KeeperSpec `json:"spec,omitempty"` Status KeeperStatus `json:"status,omitempty"` }
func NewKeeperFromKeeperInfo ¶ added in v0.5.0
func NewKeeperFromKeeperInfo(ki *KeeperInfo) *Keeper
type KeeperInfo ¶
type KeeperInfo struct { // An unique id for this info, used to know when this the keeper info // has been updated InfoUID string `json:"infoUID,omitempty"` UID string `json:"uid,omitempty"` ClusterUID string `json:"clusterUID,omitempty"` BootUUID string `json:"bootUUID,omitempty"` PostgresState *PostgresState `json:"postgresState,omitempty"` }
func (*KeeperInfo) DeepCopy ¶ added in v0.5.0
func (k *KeeperInfo) DeepCopy() *KeeperInfo
type KeeperSpec ¶ added in v0.5.0
type KeeperSpec struct{}
type KeeperStatus ¶ added in v0.5.0
type Keepers ¶ added in v0.5.0
func (Keepers) SortedKeys ¶ added in v0.5.0
type KeepersInfo ¶
type KeepersInfo map[string]*KeeperInfo
func (KeepersInfo) DeepCopy ¶ added in v0.5.0
func (k KeepersInfo) DeepCopy() KeepersInfo
type PGParameters ¶ added in v0.5.0
type PITRConfig ¶ added in v0.5.0
type PITRConfig struct { // DataRestoreCommand defines the command to execute for restoring the db // cluster data). %d is replaced with the full path to the db cluster // datadir. Use %% to embed an actual % character. DataRestoreCommand string `json:"dataRestoreCommand,omitempty"` ArchiveRecoverySettings *ArchiveRecoverySettings `json:"archiveRecoverySettings,omitempty"` RecoveryTargetSettings *RecoveryTargetSettings `json:"recoveryTargetSettings,omitempty"` }
type PostgresState ¶
type PostgresState struct { UID string `json:"uid,omitempty"` Generation int64 `json:"generation,omitempty"` ListenAddress string `json:"listenAddress,omitempty"` Port string `json:"port,omitempty"` Healthy bool `json:"healthy,omitempty"` SystemID string `json:"systemID,omitempty"` TimelineID uint64 `json:"timelineID,omitempty"` XLogPos uint64 `json:"xLogPos,omitempty"` TimelinesHistory PostgresTimelinesHistory `json:"timelinesHistory,omitempty"` PGParameters common.Parameters `json:"pgParameters,omitempty"` SynchronousStandbys []string `json:"synchronousStandbys"` OlderWalFile string `json:"olderWalFile,omitempty"` }
func (*PostgresState) DeepCopy ¶ added in v0.5.0
func (p *PostgresState) DeepCopy() *PostgresState
type PostgresTimelineHistory ¶ added in v0.4.0
type PostgresTimelinesHistory ¶ added in v0.4.0
type PostgresTimelinesHistory []*PostgresTimelineHistory
func (PostgresTimelinesHistory) GetTimelineHistory ¶ added in v0.4.0
func (tlsh PostgresTimelinesHistory) GetTimelineHistory(id uint64) *PostgresTimelineHistory
type ProxiesInfo ¶
func (ProxiesInfo) DeepCopy ¶ added in v0.10.0
func (p ProxiesInfo) DeepCopy() ProxiesInfo
func (ProxiesInfo) ToSlice ¶ added in v0.10.0
func (p ProxiesInfo) ToSlice() ProxiesInfoSlice
type ProxiesInfoSlice ¶ added in v0.10.0
type ProxiesInfoSlice []*ProxyInfo
func (ProxiesInfoSlice) Len ¶ added in v0.10.0
func (p ProxiesInfoSlice) Len() int
func (ProxiesInfoSlice) Less ¶ added in v0.10.0
func (p ProxiesInfoSlice) Less(i, j int) bool
func (ProxiesInfoSlice) Swap ¶ added in v0.10.0
func (p ProxiesInfoSlice) Swap(i, j int)
type ProxyStatus ¶ added in v0.5.0
type ProxyStatus struct { }
type RecoveryTargetSettings ¶ added in v0.5.0
type RecoveryTargetSettings struct { RecoveryTarget string `json:"recoveryTarget,omitempty"` RecoveryTargetLsn string `json:"recoveryTargetLsn,omitempty"` RecoveryTargetName string `json:"recoveryTargetName,omitempty"` RecoveryTargetTime string `json:"recoveryTargetTime,omitempty"` RecoveryTargetXid string `json:"recoveryTargetXid,omitempty"` RecoveryTargetTimeline string `json:"recoveryTargetTimeline,omitempty"` }
RecoveryTargetSettings defines the recovery target settings in the recovery.conf file (https://www.postgresql.org/docs/9.6/static/recovery-target-settings.html )
type SUReplAccessMode ¶ added in v0.10.0
type SUReplAccessMode string
const ( // Allow access from every host SUReplAccessAll SUReplAccessMode = "all" // Allow access from standby server IPs only SUReplAccessStrict SUReplAccessMode = "strict" )
func SUReplAccessModeP ¶ added in v0.10.0
func SUReplAccessModeP(s SUReplAccessMode) *SUReplAccessMode
type SentinelInfo ¶
type SentinelInfo struct {
UID 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)
type StandbySettings ¶ added in v0.5.0
type StandbySettings struct { PrimaryConninfo string `json:"primaryConninfo,omitempty"` PrimarySlotName string `json:"primarySlotName,omitempty"` RecoveryMinApplyDelay string `json:"recoveryMinApplyDelay,omitempty"` }
StandbySettings defines the standby settings in the recovery.conf file (https://www.postgresql.org/docs/9.6/static/standby-settings.html )