patroni

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: PostgreSQL Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClusterName

func ClusterName(databaseID, nodeName string) string

func ClusterPrefix

func ClusterPrefix(databaseID, nodeName string) string

func ExtractPatroniControlledGUCs

func ExtractPatroniControlledGUCs(gucs map[string]any) map[string]any

ExtractPatroniControlledGUCs extracts the GUCs that Patroni controls into a separate map that can be used in the DCS parameters. See the important rules page for more information: https://patroni.readthedocs.io/en/latest/patroni_configuration.html#important-rules Something non-obvious in that page, but explained in the main configuration page, is that dynamic parameters can also be set in the DCS section.

func IsErrorState

func IsErrorState(state State) bool

func MemberKey

func MemberKey(databaseID, nodeName, instanceID string) string

func Namespace

func Namespace() string

Types

type Authentication

type Authentication struct {
	Superuser   *User `json:"superuser,omitempty"`
	Replication *User `json:"replication,omitempty"`
	Rewind      *User `json:"rewind,omitempty"`
}

type BinNames

type BinNames struct {
	PgCtl         *string `json:"pg_ctl,omitempty"`
	Initdb        *string `json:"initdb,omitempty"`
	Pgcontroldata *string `json:"pgcontroldata,omitempty"`
	PgBasebackup  *string `json:"pg_basebackup,omitempty"`
	Postgres      *string `json:"postgres,omitempty"`
	PgIsready     *string `json:"pg_isready,omitempty"`
	PgRewind      *string `json:"pg_rewind,omitempty"`
}

type Bootstrap

type Bootstrap struct {
	DCS           *DCS                 `json:"dcs,omitempty"`
	Method        *BootstrapMethod     `json:"method,omitempty"`
	InitDB        *[]string            `json:"initdb,omitempty"`
	PostBootstrap *string              `json:"post_bootstrap,omitempty"`
	PostInit      *string              `json:"post_init,omitempty"`
	Restore       *BootstrapMethodConf `json:"restore,omitempty"`
}

type BootstrapMethod

type BootstrapMethod string
const (
	BoostrapMethodNameInitDB   BootstrapMethod = "initdb"
	BootstrapMethodNameRestore BootstrapMethod = "restore"
)

type BootstrapMethodConf

type BootstrapMethodConf struct {
	Command                  *string         `json:"command,omitempty"`
	KeepExistingRecoveryConf *bool           `json:"keep_existing_recovery_conf,omitempty"`
	NoParams                 *bool           `json:"no_params,omitempty"`
	RecoveryConf             *map[string]any `json:"recovery_conf,omitempty"`
}

type CTL

type CTL struct {
	Authentication  *CTLAuthentication `json:"authentication,omitempty"`
	Insecure        *bool              `json:"insecure,omitempty"`
	CACert          *string            `json:"cacert,omitempty"`
	CertFile        *string            `json:"certfile,omitempty"`
	KeyFile         *string            `json:"keyfile,omitempty"`
	KeyFilePassword *string            `json:"keyfile_password,omitempty"`
}

type CTLAuthentication

type CTLAuthentication struct {
	Username *string `json:"username,omitempty"`
	Password *string `json:"password,omitempty"`
}

type Callbacks

type Callbacks struct {
	OnReload     *string `json:"on_reload,omitempty"`
	OnRestart    *string `json:"on_restart,omitempty"`
	OnRoleChange *string `json:"on_role_change,omitempty"`
	OnStart      *string `json:"on_start,omitempty"`
	OnStop       *string `json:"on_stop,omitempty"`
}

type Client

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

func NewClient

func NewClient(baseURL *url.URL, client *http.Client) *Client

func (*Client) CancelRestart

func (c *Client) CancelRestart(ctx context.Context) error

func (*Client) CancelSwitchover

func (c *Client) CancelSwitchover(ctx context.Context) error

func (*Client) GetClusterStatus

func (c *Client) GetClusterStatus(ctx context.Context) (*ClusterState, error)

func (*Client) GetDynamicConfig

func (c *Client) GetDynamicConfig(ctx context.Context) (*DynamicConfig, error)

func (*Client) GetInstanceStatus

func (c *Client) GetInstanceStatus(ctx context.Context) (*InstanceStatus, error)

func (*Client) InitiateFailover

func (c *Client) InitiateFailover(ctx context.Context, failover *Failover) error

func (*Client) Liveness

func (c *Client) Liveness(ctx context.Context) error

func (*Client) PatchDynamicConfig

func (c *Client) PatchDynamicConfig(ctx context.Context, config *DynamicConfig) (*DynamicConfig, error)

func (*Client) Readiness

func (c *Client) Readiness(ctx context.Context) error

func (*Client) Reinitialize

func (c *Client) Reinitialize(ctx context.Context) error

func (*Client) Reload

func (c *Client) Reload(ctx context.Context) error

func (*Client) ScheduleRestart

func (c *Client) ScheduleRestart(ctx context.Context, restart *Restart) error

func (*Client) ScheduleSwitchover

func (c *Client) ScheduleSwitchover(ctx context.Context, switchover *Switchover, wait bool) error

type ClusterMember

type ClusterMember struct {
	// The name of the host (unique in the cluster). The members list is sorted
	// by this key
	Name *string `json:"name,omitempty"`
	// The role of this member in the cluster
	Role *ClusterRole `json:"role,omitempty"`
	// The state of this member
	State *State `json:"state,omitempty"`
	// REST API URL based on restapi->connect_address configuration
	ApiUrl *string `json:"api_url,omitempty"`
	// PostgreSQL host based on postgresql->connect_address
	Host *string `json:"host,omitempty"`
	// PostgreSQL port based on postgresql->connect_address
	Port *int `json:"port,omitempty"`
	// PostgreSQL current timeline
	Timeline *int64 `json:"timeline,omitempty"`
	// True if PostgreSQL is pending to be restarted
	PendingRestart *bool `json:"pending_restart,omitempty"`
	// True if PostgreSQL is pending to be restarted
	ScheduledRestart *bool `json:"scheduled_restart,omitempty"`
	// any tags that were set for this member
	Tags map[string]any `json:"tags,omitempty"`
	// replication lag, if applicable. We set this to -1 if patroni returns the
	// lag as 'unknown'.
	Lag *Lag `json:"lag,omitempty"`
}

func (*ClusterMember) InErrorState

func (m *ClusterMember) InErrorState() bool

func (*ClusterMember) IsLeader

func (m *ClusterMember) IsLeader() bool

func (*ClusterMember) IsRunning

func (m *ClusterMember) IsRunning() bool

type ClusterRole

type ClusterRole string
const (
	ClusterRoleLeader        ClusterRole = "leader"
	ClusterRoleStandbyLeader ClusterRole = "standby_leader"
	ClusterRoleSyncStandby   ClusterRole = "sync_standby"
	ClusterRoleQuorumStandby ClusterRole = "quorum_standby"
	ClusterRoleReplica       ClusterRole = "replica"
)

type ClusterState

type ClusterState struct {
	// List of members in the cluster
	Members []ClusterMember `json:"members,omitempty"`
	// True if cluster is in maintenance mode
	Pause *bool `json:"pause,omitempty"`
	// Populated if a switchover has been scheduled
	ScheduledSwitchover *ScheduledSwitchover `json:"scheduled_switchover,omitempty"`
}

func (*ClusterState) Leader

func (c *ClusterState) Leader() (ClusterMember, bool)

func (*ClusterState) MostAlignedReplica

func (c *ClusterState) MostAlignedReplica() (ClusterMember, bool)

type Config

type Config struct {
	Name       *string     `json:"name,omitempty"`
	Namespace  *string     `json:"namespace,omitempty"`
	Scope      *string     `json:"scope,omitempty"`
	Log        *Log        `json:"log,omitempty"`
	Bootstrap  *Bootstrap  `json:"bootstrap,omitempty"`
	Etcd3      *Etcd       `json:"etcd3,omitempty"`
	Postgresql *PostgreSQL `json:"postgresql,omitempty"`
	RestAPI    *RestAPI    `json:"restapi,omitempty"`
	CTL        *CTL        `json:"ctl,omitempty"`
	Watchdog   *Watchdog   `json:"watchdog,omitempty"`
	Tags       *Tags       `json:"tags,omitempty"`
}

type DCS

type DCS struct {
	LoopWait              *int               `json:"loop_wait,omitempty"`
	TTL                   *int               `json:"ttl,omitempty"`
	RetryTimeout          *int               `json:"retry_timeout,omitempty"`
	MaximumLagOnFailover  *int64             `json:"maximum_lag_on_failover,omitempty"`
	MaximumLagOnSyncNode  *int64             `json:"maximum_lag_on_syncnode,omitempty"`
	MaxTimelinesHistory   *int               `json:"max_timelines_history,omitempty"`
	PrimaryStartTimeout   *int               `json:"primary_start_timeout,omitempty"`
	PrimaryStopTimeout    *int               `json:"primary_stop_timeout,omitempty"`
	SynchronousMode       *string            `json:"synchronous_mode,omitempty"`
	SynchronousModeStrict *bool              `json:"synchronous_mode_strict,omitempty"`
	SynchronousModeCount  *int               `json:"synchronous_mode_count,omitempty"`
	FailsafeMode          *bool              `json:"failsafe_mode,omitempty"`
	Postgresql            *DCSPostgreSQL     `json:"postgresql,omitempty"`
	StandbyCluster        *DCSStandbyCluster `json:"standby_cluster,omitempty"`
	MemberSlotsTtl        *string            `json:"member_slots_ttl,omitempty"`
	Slots                 *map[string]Slot   `json:"slots,omitempty"`
	IgnoreSlots           *[]IgnoreSlot      `json:"ignore_slots,omitempty"`
}

type DCSPostgreSQL

type DCSPostgreSQL struct {
	UsePgRewind  *bool           `json:"use_pg_rewind,omitempty"`
	UseSlots     *bool           `json:"use_slots,omitempty"`
	RecoveryConf *map[string]any `json:"recovery_conf,omitempty"`
	Parameters   *map[string]any `json:"parameters,omitempty"`
	PgHba        *[]string       `json:"pg_hba,omitempty"`
	PgIdent      *[]string       `json:"pg_ident,omitempty"`
}

type DCSStandbyCluster

type DCSStandbyCluster struct {
	Host                  *string   `json:"host,omitempty"`
	Port                  *int      `json:"port,omitempty"`
	PrimarySlotName       *string   `json:"primary_slot_name,omitempty"`
	CreateReplicaMethods  *[]string `json:"create_replica_methods,omitempty"`
	RestoreCommand        *string   `json:"restore_command,omitempty"`
	ArchiveCleanupCommand *string   `json:"archive_cleanup_command,omitempty"`
	RecoveryMinApplyDelay *int      `json:"recovery_min_apply_delay,omitempty"`
}

type DynamicConfig

type DynamicConfig struct {
	// The number of seconds the loop will sleep. Default value: 10, minimum
	// possible value: 1
	LoopWait *int `json:"loop_wait,omitempty"`
	// The TTL to acquire the leader lock (in seconds). Think of it as the
	// length of time before initiation of the automatic failover process.
	// Default value: 30, minimum possible value: 20
	TTL *int `json:"ttl,omitempty"`
	// Timeout for DCS and PostgreSQL operation retries (in seconds). DCS or
	// network issues shorter than this will not cause Patroni to demote the
	// leader. Default value: 10, minimum possible value: 3
	RetryTimeout *int `json:"retry_timeout,omitempty"`
	// The maximum bytes a follower may lag to be able to participate in leader
	// election.
	MaximumLagOnFailover *int64 `json:"maximum_lag_on_failover,omitempty"`
	// The maximum bytes a synchronous follower may lag before it is considered
	// as an unhealthy candidate and swapped by healthy asynchronous follower.
	// Patroni utilize the max replica lsn if there is more than one follower,
	// otherwise it will use leader’s current wal lsn. Default is -1, Patroni
	// will not take action to swap synchronous unhealthy follower when the
	// value is set to 0 or below.
	MaximumLagOnSyncNode *int64 `json:"maximum_lag_on_syncnode,omitempty"`
	// maximum number of timeline history items kept in DCS. Default value: 0.
	// When set to 0, it keeps the full history in DCS.
	MaxTimelinesHistory *int `json:"max_timelines_history,omitempty"`
	// The amount of time a primary is allowed to recover from failures before
	// failover is triggered (in seconds). Default is 300 seconds. When set to 0
	// failover is done immediately after a crash is detected if possible.
	PrimaryStartTimeout *int `json:"primary_start_timeout,omitempty"`
	// The number of seconds Patroni is allowed to wait when stopping Postgres
	// and effective only when synchronous_mode is enabled.
	PrimaryStopTimeout *int `json:"primary_stop_timeout,omitempty"`
	// Turns on synchronous replication mode.
	SynchronousMode *SynchronousMode `json:"synchronous_mode,omitempty"`
	// Prevents disabling synchronous replication if no synchronous replicas are
	// available, blocking all client writes to the primary.
	SynchronousModeStrict *bool `json:"synchronous_mode_strict,omitempty"`
	// If synchronous_mode is enabled, this parameter is used by Patroni to
	// manage the precise number of synchronous standby instances and adjusts
	// the state in DCS and the synchronous_standby_names parameter in
	// PostgreSQL as members join and leave.
	SynchronousNodeCount *int `json:"synchronous_node_count,omitempty"`
	// Enables DCS Failsafe Mode. Defaults to false.
	FailsafeMode *bool                    `json:"failsafe_mode,omitempty"`
	PostgreSQL   *DynamicPostgreSQLConfig `json:"postgresql,omitempty"`
	// If this section is defined, we want to bootstrap a standby cluster.
	StandbyCluster *DynamicStandbyClusterConfig `json:"standby_cluster,omitempty"`
	// Retention time of physical replication slots for replicas when they are
	// shut down. Default value: 30min. Set it to 0 if you want to keep the old
	// behavior (when the member key expires from DCS, the slot is immediately
	// removed).
	MemberSlotsTtl *int `json:"member_slots_ttl,omitempty"`
	// Define permanent replication slots. These slots will be preserved during
	// switchover/failover. Permanent slots that don’t exist will be created by
	// Patroni. With PostgreSQL 11 onwards permanent physical slots are created
	// on all nodes and their position is advanced every loop_wait seconds.
	Slots *map[string]Slot `json:"slots,omitempty"`
	// List of sets of replication slot properties for which Patroni should
	// ignore matching slots. This configuration/feature/etc. is useful when
	// some replication slots are managed outside of Patroni. Any subset of
	// matching properties will cause a slot to be ignored.
	IgnoreSlots *[]IgnoreSlot `json:"ignore_slots,omitempty"`
	// Stops Patroni from making changes to the cluster.
	Pause bool `json:"pause"`
}

type DynamicPostgreSQLConfig

type DynamicPostgreSQLConfig struct {
	// Whether or not to use pg_rewind. Defaults to false. Note that either the
	// cluster must be initialized with data page checksums (--data-checksums
	// option for initdb) and/or wal_log_hints must be set to on, or pg_rewind
	// will not work.
	UsePgRewind *bool `json:"use_pg_rewind,omitempty"`
	// Whether or not to use replication slots. Defaults to true on PostgreSQL
	// 9.4+.
	UseSlots *bool `json:"use_slots,omitempty"`
	// Configuration parameters (GUCs) for Postgres in format {max_connections:
	// 100, wal_level: "replica", max_wal_senders: 10, wal_log_hints: "on"}.
	// Many of these are required for replication to work.
	Parameters *map[string]any `json:"parameters,omitempty"`
	// List of lines that Patroni will use to generate pg_hba.conf. Patroni
	// ignores this parameter if hba_file PostgreSQL parameter is set to a
	// non-default value.
	PgHba *[]string `json:"pg_hba,omitempty"`
	// List of lines that Patroni will use to generate pg_ident.conf. Patroni
	// ignores this parameter if ident_file PostgreSQL parameter is set to a
	// non-default value.
	PgIdent *[]string `json:"pg_ident,omitempty"`
}

type DynamicStandbyClusterConfig

type DynamicStandbyClusterConfig struct {
	// An address of remote node
	Host *string `json:"host,omitempty"`
	// A port of remote node
	Port *int `json:"port,omitempty"`
	// Which slot on the remote node to use for replication. This parameter is
	// optional, the default value is derived from the instance name (see
	// function slot_name_from_member_name).
	PrimarySlotName *string `json:"primary_slot_name,omitempty"`
	// An ordered list of methods that can be used to bootstrap standby leader
	// from the remote primary, can be different from the list defined in
	// PostgreSQL
	CreateReplicaMethods *string `json:"create_replica_methods,omitempty"`
	// Command to restore WAL records from the remote primary to nodes in a
	// standby cluster, can be different from the list defined in PostgreSQL
	RestoreCommand *string `json:"restore_command,omitempty"`
	// Cleanup command for standby leader
	ArchiveCleanupCommand *string `json:"archive_cleanup_command,omitempty"`
	// How long to wait before actually apply WAL records on a standby leader
	RecoveryMinApplyDelay *string `json:"recovery_min_apply_delay,omitempty"`
}

type Etcd

type Etcd struct {
	Host       *string   `json:"host,omitempty"`
	Hosts      *[]string `json:"hosts,omitempty"`
	UseProxies *bool     `json:"use_proxies,omitempty"`
	URL        *string   `json:"url,omitempty"`
	Proxy      *string   `json:"proxy,omitempty"`
	SRV        *string   `json:"srv,omitempty"`
	SRVSuffix  *string   `json:"srv_suffix,omitempty"`
	Protocol   *string   `json:"protocol,omitempty"`
	Username   *string   `json:"username,omitempty"`
	Password   *string   `json:"password,omitempty"`
	CACert     *string   `json:"cacert,omitempty"`
	Cert       *string   `json:"cert,omitempty"`
	Key        *string   `json:"key,omitempty"`
}

type Failover

type Failover struct {
	Leader    *string `json:"leader,omitempty"`
	Candidate *string `json:"candidate,omitempty"`
}

type IgnoreSlot

type IgnoreSlot struct {
	Name     *string   `json:"name,omitempty"`
	Type     *SlotType `json:"type,omitempty"`
	Database *string   `json:"database,omitempty"`
	Plugin   *string   `json:"plugin,omitempty"`
}

type InstanceRole

type InstanceRole string
const (
	InstanceRoleReplica       InstanceRole = "replica"
	InstanceRolePrimary       InstanceRole = "primary"
	InstanceRoleUninitialized InstanceRole = "uninitialized"
)

func (InstanceRole) String

func (i InstanceRole) String() string

type InstanceStatus

type InstanceStatus struct {
	// Postgres state
	State *State `json:"state,omitempty"`
	// pg_postmaster_start_time()
	PostmasterStartTime *string `json:"pg_postmaster_start_time,omitempty"`
	// Based on pg_is_in_recovery() output
	Role *InstanceRole `json:"role,omitempty"`
	// Postgres version without periods, e.g. '150002' for Postgres 15.2
	ServerVersion *int64 `json:"server_version,omitempty"`
	// Structure depends on role
	XLog *XLog `json:"xlog,omitempty"`
	// True if replication mode is synchronous and this is a sync standby
	SyncStandby *bool `json:"sync_standby,omitempty"`
	// True if replication mode is quorum and this is a quorum standby
	QuorumStandby *bool `json:"quorum_standby,omitempty"`
	// PostgreSQL primary node timeline
	Timeline *int64 `json:"timeline,omitempty"`
	// One entry for each replication connection
	Replication []Replication `json:"replication,omitempty"`
	// True if cluster is in maintenance mode
	Pause *bool `json:"pause,omitempty"`
	// True if cluster has no node holding the leader lock
	ClusterUnlocked *bool `json:"cluster_unlocked,omitempty"`
	// True if DCS failsafe mode is currently active
	FailsafeModeIsActive *bool `json:"failsafe_mode_is_active,omitempty"`
	// Epoch timestamp DCS was last reached by Patroni
	DCSLastSeen *int64 `json:"dcs_last_seen,omitempty"`
	// True if PostgreSQL needs to be restarted to get new configuration
	PendingRestart *bool `json:"pending_restart,omitempty"`
}

func (*InstanceStatus) InErrorState

func (s *InstanceStatus) InErrorState() bool

func (*InstanceStatus) InRunningState

func (s *InstanceStatus) InRunningState() bool

func (*InstanceStatus) IsPrimary

func (s *InstanceStatus) IsPrimary() bool

type Lag

type Lag int64

func (*Lag) IsKnown

func (l *Lag) IsKnown() bool

func (*Lag) UnmarshalJSON

func (l *Lag) UnmarshalJSON(data []byte) error

type Log

type Log struct {
	Type           *LogType             `json:"type,omitempty"`
	Level          *LogLevel            `json:"level,omitempty"`
	TracebackLevel *TracebackLevel      `json:"traceback_level,omitempty"`
	Format         *[]string            `json:"format,omitempty"`
	DateFormat     *string              `json:"dateformat,omitempty"`
	StaticFields   *map[string]string   `json:"static_fields,omitempty"`
	MaxQueueSize   *int                 `json:"max_queue_size,omitempty"`
	Dir            *string              `json:"dir,omitempty"`
	Mode           *string              `json:"mode,omitempty"`
	FileNum        *int                 `json:"file_num,omitempty"`
	FileSize       *int                 `json:"file_size,omitempty"`
	Loggers        *map[string]LogLevel `json:"loggers,omitempty"`
}

type LogLevel

type LogLevel string
const (
	LogLevelDebug    LogLevel = "DEBUG"
	LogLevelInfo     LogLevel = "INFO"
	LogLevelWarning  LogLevel = "WARNING"
	LogLevelError    LogLevel = "ERROR"
	LogLevelCritical LogLevel = "CRITICAL"
)

type LogType

type LogType string
const (
	LogTypePlain LogType = "plain"
	LogTypeJson  LogType = "json"
)

type PostgreSQL

type PostgreSQL struct {
	// Database                               *string            `json:"database,omitempty"`
	Authentication                         *Authentication    `json:"authentication,omitempty"`
	Callbacks                              *Callbacks         `json:"callbacks,omitempty"`
	ConnectAddress                         *string            `json:"connect_address,omitempty"`
	ProxyAddress                           *string            `json:"proxy_address,omitempty"`
	CreateReplicaMethods                   *[]string          `json:"create_replica_methods,omitempty"`
	DataDir                                *string            `json:"data_dir,omitempty"`
	ConfigDir                              *string            `json:"config_dir,omitempty"`
	BinDir                                 *string            `json:"bin_dir,omitempty"`
	BinName                                *BinNames          `json:"bin_name,omitempty"`
	Listen                                 *string            `json:"listen,omitempty"`
	UseUnixSocket                          *bool              `json:"use_unix_socket,omitempty"`
	UseUnixSocketRepl                      *bool              `json:"use_unix_socket_repl,omitempty"`
	Pgpass                                 *string            `json:"pgpass,omitempty"`
	RecoveryConf                           *map[string]any    `json:"recovery_conf,omitempty"`
	CustomConf                             *string            `json:"custom_conf,omitempty"`
	Parameters                             *map[string]any    `json:"parameters,omitempty"`
	PgHba                                  *[]string          `json:"pg_hba,omitempty"`
	PgIdent                                *[]string          `json:"pg_ident,omitempty"`
	PgCtlTimeout                           *int               `json:"pg_ctl_timeout,omitempty"`
	UsePgRewind                            *bool              `json:"use_pg_rewind,omitempty"`
	RemoveDataDirectoryOnRewindFailure     *bool              `json:"remove_data_directory_on_rewind_failure,omitempty"`
	RemoveDataDirectoryOnDivergedTimelines *bool              `json:"remove_data_directory_on_diverged_timelines,omitempty"`
	ReplicaMethod                          *map[string]string `json:"replica_method,omitempty"`
	PrePromote                             *string            `json:"pre_promote,omitempty"`
	BeforeStop                             *string            `json:"before_stop,omitempty"`
	BaseBackup                             *[]any             `json:"basebackup,omitempty"`
}

type Replication

type Replication struct {
	// pg_stat_activity.application_name
	ApplicationName *string `json:"application_name,omitempty"`
	// pg_stat_activity.client_addr
	ClientAddr *string `json:"client_addr,omitempty"`
	// pg_stat_replication.state
	State *string `json:"state,omitempty"`
	// pg_stat_replication.sync_priority
	SyncPriority *int64 `json:"sync_priority,omitempty"`
	// pg_stat_replication.sync_state
	SyncState *string `json:"sync_state,omitempty"`
	// pg_stat_activity.usename
	Usename *string `json:"usename,omitempty"`
}

type RestAPI

type RestAPI struct {
	ConnectAddress          *string                `json:"connect_address,omitempty"`
	Listen                  *string                `json:"listen,omitempty"`
	Authentication          *RestAPIAuthentication `json:"authentication,omitempty"`
	CertFile                *string                `json:"certfile,omitempty"`
	KeyFile                 *string                `json:"keyfile,omitempty"`
	KeyFilePassword         *string                `json:"keyfile_password,omitempty"`
	CAFile                  *string                `json:"cafile,omitempty"`
	Ciphers                 *string                `json:"ciphers,omitempty"`
	VerifyClient            *VerifyClient          `json:"verify_client,omitempty"`
	Allowlist               *[]string              `json:"allowlist,omitempty"`
	AllowlistIncludeMembers *bool                  `json:"allowlist_include_members,omitempty"`
	HttpExtraHeaders        *map[string]string     `json:"http_extra_headers,omitempty"`
	HttpsExtraHeaders       *map[string]string     `json:"https_extra_headers,omitempty"`
	RequestQueueSize        *int                   `json:"request_queue_size,omitempty"`
}

type RestAPIAuthentication

type RestAPIAuthentication struct {
	Username *string `json:"username,omitempty"`
	Password *string `json:"password,omitempty"`
}

type Restart

type Restart struct {
	// If set to true Patroni will restart PostgreSQL only when restart is
	// pending in order to apply some changes in the PostgreSQL config.
	RestartPending *bool `json:"restart_pending,omitempty"`
	// Perform restart only if the current role of the node matches with the
	// role from the POST request.
	Role *string `json:"role,omitempty"`
	// Perform restart only if the current version of postgres is smaller than
	// specified in the POST request, e.g. '15.2'
	PostgresVersion *string `json:"postgres_version,omitempty"`
	// How long we should wait before PostgreSQL starts accepting connections.
	// Overrides primary_start_timeout.
	Timeout *int `json:"timeout,omitempty"`
	// Timestamp with time zone, schedule the restart somewhere in the future.
	Schedule *time.Time `json:"schedule,omitempty"`
}

type ScheduledSwitchover

type ScheduledSwitchover struct {
	// timestamp when switchover was scheduled to occur;
	At *string `json:"at,omitempty"`
	// name of the member to be demoted;
	From *string `json:"from,omitempty"`
	// name of the member to be promoted.
	To *string `json:"to,omitempty"`
}

type Slot

type Slot struct {
	Type     *SlotType `json:"type,omitempty"`
	Database *string   `json:"database,omitempty"`
	Plugin   *string   `json:"plugin,omitempty"`
}

type SlotType

type SlotType string
const (
	SlotTypePhysical SlotType = "physical"
	SlotTypeLogical  SlotType = "logical"
)

type State

type State string
const (
	StateStopping                     State = "stopping"
	StateStopped                      State = "stopped"
	StateStopFailed                   State = "stop failed"
	StateCrashed                      State = "crashed"
	StateRunning                      State = "running"
	StateStarting                     State = "starting"
	StateStartFailed                  State = "start failed"
	StateRestarting                   State = "restarting"
	StateRestartFailed                State = "restart failed"
	StateInitializingNewCluster       State = "initializing new cluster"
	StateInitDBFailed                 State = "initdb failed"
	StateRunningCustomBootstrapScript State = "running custom bootstrap script"
	StateCustomBootstrapFailed        State = "custom bootstrap failed"
	StateCreatingReplica              State = "creating replica"
	StateUnknown                      State = "unknown"
	StateStreaming                    State = "streaming"
)

func (State) String

func (s State) String() string

type Switchover

type Switchover struct {
	Leader      *string    `json:"leader,omitempty"`
	Candidate   *string    `json:"candidate,omitempty"`
	ScheduledAt *time.Time `json:"scheduled_at,omitempty"`
}

type SynchronousMode

type SynchronousMode string
const (
	SynchronousModeOff    SynchronousMode = "off"
	SynchronousModeOn     SynchronousMode = "on"
	SynchronousModeQuorum SynchronousMode = "quorum"
)

type Tags

type Tags struct {
	CloneFrom        *bool   `json:"clonefrom,omitempty"`
	NoLoadBalance    *bool   `json:"noloadbalance,omitempty"`
	ReplicateFrom    *string `json:"replicatefrom,omitempty"`
	NoSync           *bool   `json:"nosync,omitempty"`
	NoFailover       *bool   `json:"nofailover,omitempty"`
	FailoverPriority *int    `json:"failover_priority,omitempty"`
	NoStream         *bool   `json:"nostream,omitempty"`
	DatabaseID       *string `json:"database_id,omitempty"`
	Region           *string `json:"region,omitempty"`
}

type TracebackLevel

type TracebackLevel string
const (
	TracebackLevelDebug TracebackLevel = "DEBUG"
	TracebackLevelError TracebackLevel = "ERROR"
)

type User

type User struct {
	Username       *string `json:"username,omitempty"`
	Password       *string `json:"password,omitempty"`
	SSLMode        *string `json:"sslmode,omitempty"`
	SSLKey         *string `json:"sslkey,omitempty"`
	SSLPassword    *string `json:"sslpassword,omitempty"`
	SSLCert        *string `json:"sslcert,omitempty"`
	SSLRootCert    *string `json:"sslrootcert,omitempty"`
	SSLCrl         *string `json:"sslcrl,omitempty"`
	SSLCrlDir      *string `json:"sslcrldir,omitempty"`
	GSSEncMode     *string `json:"gssencmode,omitempty"`
	ChannelBinding *string `json:"channel_binding,omitempty"`
}

type VerifyClient

type VerifyClient string
const (
	VerifyClientNone     VerifyClient = "none"
	VerifyClientOptional VerifyClient = "optional"
	VerifyClientRequired VerifyClient = "required"
)

type Watchdog

type Watchdog struct {
	Mode         *WatchdogMode `json:"mode,omitempty"`
	Device       *string       `json:"device,omitempty"`
	SafetyMargin *int          `json:"safety_margin,omitempty"`
}

type WatchdogMode

type WatchdogMode string
const (
	WatchdogModeOff       WatchdogMode = "off"
	WatchdogModeAutomatic WatchdogMode = "automatic"
	WatchdogModeRequired  WatchdogMode = "required"
)

type XLog

type XLog struct {
	// pg_current_wal_flush_lsn() - populated if role is primary
	Location *int64 `json:"location,omitempty"`
	// pg_wal_lsn_diff(pg_last_wal_receive_lsn(), '0/0') - populated if role is
	// replica
	ReceivedLocation *int64 `json:"received_location,omitempty"`
	// pg_wal_lsn_diff(pg_last_wal_replay_lsn(), '0/0) - populated if role is
	// replica
	ReplayedLocation *int64 `json:"replayed_location,omitempty"`
	// pg_last_xact_replay_timestamp - populated if role is replica
	ReplayedTimestamp *string `json:"replayed_timestamp,omitempty"`
	// pg_is_wal_replay_paused() - populated if role is replica
	Paused *bool `json:"paused,omitempty"`
}

Jump to

Keyboard shortcuts

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