Documentation
¶
Index ¶
- Constants
- type Admin
- func (a *Admin) Close()
- func (a *Admin) ConfigureAsyncMode(ctx context.Context, addr string) error
- func (a *Admin) ConfigureStandby(ctx context.Context, ...) error
- func (a *Admin) ConfigureSyncMode(ctx context.Context, addr, standbyList string) error
- func (a *Admin) Connections() IAdminConnections
- func (a *Admin) GetReplicationStatus(ctx context.Context) *ReplicationInfo
- type AdminConnections
- func (cnx *AdminConnections) Add(addr string) error
- func (cnx *AdminConnections) AddAll(addrs []string)
- func (cnx *AdminConnections) Get(addr string) (IClient, error)
- func (cnx *AdminConnections) GetAll() map[string]IClient
- func (cnx *AdminConnections) GetSelected(addrs []string) map[string]IClient
- func (cnx *AdminConnections) Reconnect(addr string) error
- func (cnx *AdminConnections) Remove(addr string)
- func (cnx *AdminConnections) ReplaceAll(addrs []string)
- func (cnx *AdminConnections) Reset()
- type AdminOptions
- type Client
- func (c *Client) Close() error
- func (c *Client) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (c *Client) Query(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (c *Client) QueryRow(ctx context.Context, input interface{}, query string, args ...any) error
- type IAdmin
- type IAdminConnections
- type IClient
- type Node
- type Nodes
- type ReplicationInfo
Constants ¶
const ( // DefaultPostgresPort define the default Postgres Port DefaultPostgresPort = 5432 // PostgresPrimaryRole Postgres role primary PostgresPrimaryRole = "Primary" // PostgresStandbyRole Postgres role standby PostgresStandbyRole = "Standby" )
const (
// ErrNotFound cannot find a node to connect to
ErrNotFound = "unable to find a node to connect"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Admin ¶
type Admin struct {
// contains filtered or unexported fields
}
Admin wraps redis cluster admin logic
func (*Admin) Close ¶
func (a *Admin) Close()
Close used to close all possible resources instanciate by the Admin
func (*Admin) ConfigureAsyncMode ¶
func (*Admin) ConfigureStandby ¶
func (*Admin) ConfigureSyncMode ¶
func (*Admin) Connections ¶
func (a *Admin) Connections() IAdminConnections
Connections returns the connection map of all clients
func (*Admin) GetReplicationStatus ¶
func (a *Admin) GetReplicationStatus(ctx context.Context) *ReplicationInfo
GetReplicationStatus return the Nodes infos for all nodes
type AdminConnections ¶
type AdminConnections struct {
// contains filtered or unexported fields
}
AdminConnections connection map for mysql replication cluster currently the admin connection is not threadSafe since it is only use in the Events thread.
func (*AdminConnections) Add ¶
func (cnx *AdminConnections) Add(addr string) error
Add connect to the given address and register the client connection to the map
func (*AdminConnections) AddAll ¶
func (cnx *AdminConnections) AddAll(addrs []string)
AddAll connect to the given list of addresses and register them in the map fail silently
func (*AdminConnections) Get ¶
func (cnx *AdminConnections) Get(addr string) (IClient, error)
Get returns a client connection for the given adress, connects if the connection is not in the map yet
func (*AdminConnections) GetAll ¶
func (cnx *AdminConnections) GetAll() map[string]IClient
GetAll returns a map of all clients per address
func (*AdminConnections) GetSelected ¶
func (cnx *AdminConnections) GetSelected(addrs []string) map[string]IClient
GetSelected returns a map of clients based on the input addresses
func (*AdminConnections) Reconnect ¶
func (cnx *AdminConnections) Reconnect(addr string) error
Reconnect force a reconnection on the given address is the adress is not part of the map, act like Add
func (*AdminConnections) Remove ¶
func (cnx *AdminConnections) Remove(addr string)
Remove disconnect and remove the client connection from the map
func (*AdminConnections) ReplaceAll ¶
func (cnx *AdminConnections) ReplaceAll(addrs []string)
ReplaceAll clear the pool and re-populate it with new connections fail silently
func (*AdminConnections) Reset ¶
func (cnx *AdminConnections) Reset()
Reset close all connections and clear the connection map
type AdminOptions ¶
AdminOptions optional options for redis admin
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client structure representing a client connection to pgsql
type IAdmin ¶
type IAdmin interface {
// Connections returns the connection map of all clients
Connections() IAdminConnections
// Close the admin connections
Close()
// GetReplicationStatus return the Nodes infos for all nodes
GetReplicationStatus(ctx context.Context) *ReplicationInfo
// ConfigureStandby set postgres standby primary connect info
ConfigureStandby(ctx context.Context, addr, nodeName, sourceHost, sourcePort, replicationUser, replicationPwd string) error
// ConfigureSyncMode set postgres replication to synchronous
ConfigureSyncMode(ctx context.Context, addr, standbyList string) error
// ConfigureAsyncMode set postgres replication to asynchronous
ConfigureAsyncMode(ctx context.Context, addr string) error
}
IAdmin mysql admin interface
type IAdminConnections ¶
type IAdminConnections interface {
// AddAll connect to the given list of addresses and
// register them in the map
// fail silently
AddAll(addrs []string)
// Add connect to the given address and
// register the client connection to the pool
Add(addr string) error
// Reconnect force a reconnection on the given address
// if the adress is not part of the map, act like Add
Reconnect(addr string) error
// Remove disconnect and remove the client connection from the map
Remove(addr string)
// ReplaceAll clear the map and re-populate it with new connections
// fail silently
ReplaceAll(addrs []string)
// Reset close all connections and clear the connection map
Reset()
// Get returns a client connection for the given address,
// connects if the connection is not in the map yet
Get(addr string) (IClient, error)
// GetAll returns a map of all clients per address
GetAll() map[string]IClient
//GetSelected returns a map of clients based on the input addresses
GetSelected(addrs []string) map[string]IClient
}
IAdminConnections interface representing the map of admin connections to mysql nodes
func NewAdminConnections ¶
func NewAdminConnections(addrs []string, options *AdminOptions, log logr.Logger) IAdminConnections
NewAdminConnections returns and instance of AdminConnectionsInterface
type IClient ¶
type IClient interface {
// Close closes the connection.
Close() error
// Exec calls the given query like
Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
Query(ctx context.Context, query string, args ...any) (*sql.Rows, error)
QueryRow(ctx context.Context, input interface{}, query string, args ...any) error
}
IClient pgsql client interface
type Node ¶
type Node struct {
Host string
Port int
Role string
ReplicationStat []string
DataDir string
ReplicationMode string
WalDiff int
}
func NewDefaultNode ¶
func NewDefaultNode() *Node
NewDefaultNode builds and returns new defaultNode instance
func (*Node) GetRole ¶
func (n *Node) GetRole() composev1alpha1.PostgresReplicationRole
GetRole return the Postgres Replication Node GetRole
type ReplicationInfo ¶
func NewReplicationInfo ¶
func NewReplicationInfo() *ReplicationInfo