Documentation
¶
Index ¶
- func New(ctx context.Context, cfg PostgresLeaderElectionConfig) (leaderelection.LeaderElector, error)
- func NewWithConn(ctx context.Context, conn *pgx.Conn, cfg PostgresLeaderElectionConfig) (leaderelection.LeaderElector, error)
- type PostgresLeaderElection
- func (ple *PostgresLeaderElection) AcquireLeadership(ctx context.Context) (bool, error)
- func (ple *PostgresLeaderElection) CheckLeadership(ctx context.Context) (bool, error)
- func (ple *PostgresLeaderElection) Close()
- func (ple *PostgresLeaderElection) RelinquishLeadership(ctx context.Context) (bool, error)
- func (ple *PostgresLeaderElection) Run(ctx context.Context) error
- type PostgresLeaderElectionConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(ctx context.Context, cfg PostgresLeaderElectionConfig) (leaderelection.LeaderElector, error)
Initialize leader election with postgres DB parameters and lock id
func NewWithConn ¶
func NewWithConn(ctx context.Context, conn *pgx.Conn, cfg PostgresLeaderElectionConfig) (leaderelection.LeaderElector, error)
Initialize leader election with postgres DB connection and lock id. Caller must have connected to postgres and gives us a connection to work with. DB parameters can be skipped in this case. Please note, this DB connection will dedicated for leader election only.
Types ¶
type PostgresLeaderElection ¶
type PostgresLeaderElection struct {
leaderelection.LeaderElection
// contains filtered or unexported fields
}
func (*PostgresLeaderElection) AcquireLeadership ¶ added in v0.1.5
func (ple *PostgresLeaderElection) AcquireLeadership(ctx context.Context) (bool, error)
func (*PostgresLeaderElection) CheckLeadership ¶ added in v0.1.5
func (ple *PostgresLeaderElection) CheckLeadership(ctx context.Context) (bool, error)
func (*PostgresLeaderElection) Close ¶ added in v0.1.6
func (ple *PostgresLeaderElection) Close()
Close the election
func (*PostgresLeaderElection) RelinquishLeadership ¶
func (ple *PostgresLeaderElection) RelinquishLeadership(ctx context.Context) (bool, error)
Relinquish leadership. An error will be returned if caller is not the leader.
type PostgresLeaderElectionConfig ¶
type PostgresLeaderElectionConfig struct {
Host string
Port uint16
Secure string
User string
Password string
Database string
leaderelection.LeaderElectionConfig
}
Postgres connection parameters and lock id
Click to show internal directories.
Click to hide internal directories.