redis

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

Initialize leader election with redis parameters and lock id

func NewWithConn

Initialize leader election with redis client and lock id. Caller must have connected to redis and gives us a client to work with. Redis parameters can be skipped in this case. Please note, this Redis client will be dedicated for leader election only. Redis implementation will ignore RelinquishIntervalSpec. Redis distributed locking described here https://redis.io/docs/latest/develop/use/patterns/distributed-locks/, relies on TTL of the SET value. This crucially covers for the case where the instance holding the lock just vanishes. RelinquishIntervalSpec is used for cases where the user wants leadership handoff every day for e.g. Setting TTL to a day will result in a very long wait time before leadership handoff takes place in case where the leader vanishes.

Types

type RedisLeaderElection

type RedisLeaderElection struct {
	leaderelection.LeaderElection
	// contains filtered or unexported fields
}

func (*RedisLeaderElection) AcquireLeadership added in v0.1.5

func (rle *RedisLeaderElection) AcquireLeadership(ctx context.Context) (bool, error)

func (*RedisLeaderElection) CheckLeadership added in v0.1.5

func (rle *RedisLeaderElection) CheckLeadership(ctx context.Context) (bool, error)

func (*RedisLeaderElection) Close added in v0.1.6

func (rle *RedisLeaderElection) Close()

Close the election

func (*RedisLeaderElection) RelinquishLeadership

func (rle *RedisLeaderElection) RelinquishLeadership(ctx context.Context) (bool, error)

Relinquish leadership. A follower calling this function will be returned an error.

func (*RedisLeaderElection) Run

func (rle *RedisLeaderElection) Run(ctx context.Context) error

Run the election

type RedisLeaderElectionConfig

type RedisLeaderElectionConfig struct {
	Host               string
	Port               uint16
	Secure             bool
	InsecureSkipVerify bool
	Password           string

	leaderelection.LeaderElectionConfig
}

Redis client parameters and lock id

Jump to

Keyboard shortcuts

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