pgxelection

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const LevelTrace = slog.Level(-8)
View Source
const MaxChannelLen = 63

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterPgStore

type ClusterPgStore interface {
	Nodes() (map[string]*electiontypes.ClusterNode, error)
}

ClusterPgStore provides an interface that is used to enumerate a secondary list of nodes. Typically, this list comes from a database table and can be used to verify that a cluster is healthy.

type FollowResult

type FollowResult bool
const (
	FollowResultPromote FollowResult = true
	FollowResultStop    FollowResult = false
)

type Follower

type Follower interface {
	Follow() FollowResult
	Promote()
}

type PgNotifier

type PgNotifier interface {
	Notify(channel string, msgBytes []byte) error
}

type PgxFollower

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

func NewPgxFollower

func NewPgxFollower(cfg PgxFollowerConfig) *PgxFollower

func (*PgxFollower) Follow

func (p *PgxFollower) Follow() (result FollowResult)

func (*PgxFollower) Promote

func (p *PgxFollower) Promote()

type PgxFollowerConfig

type PgxFollowerConfig struct {
	Queue         Queue
	Broadcaster   broadcaster.Broadcaster
	Notifier      PgNotifier
	LeaderChannel string
	Address       string
	StopChan      chan bool
	Timeout       time.Duration
}

type PgxLeader

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

func NewPgxLeader

func NewPgxLeader(cfg PgxLeaderConfig) *PgxLeader

func (*PgxLeader) Key

func (p *PgxLeader) Key() string

func (*PgxLeader) Lead

func (p *PgxLeader) Lead() error

type PgxLeaderConfig

type PgxLeaderConfig struct {
	Store           ClusterPgStore
	Broadcaster     broadcaster.Broadcaster
	Notifier        PgNotifier
	TaskHandler     rselection.TaskHandler
	LeaderChannel   string
	FollowerChannel string
	MessagesChannel string
	Address         string
	StopChan        chan bool
	PingInterval    time.Duration
	SweepInterval   time.Duration
	MaxPingAge      time.Duration
}

type PgxPgNotifier

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

func NewPgxPgNotifier

func NewPgxPgNotifier(cfg PgxPgNotifierConfig) *PgxPgNotifier

func (*PgxPgNotifier) Notify

func (p *PgxPgNotifier) Notify(channel string, msgBytes []byte) error

type PgxPgNotifierConfig

type PgxPgNotifierConfig struct {
	Pool *pgxpool.Pool
}

type Queue

type Queue interface {
	Push(assumeLeader electiontypes.AssumeLeader) error
}

Queue is not provided by the election library. Implement this interface. When new leadership is needed, an `electiontypes.AssumeLeader` job will be pushed to the queue.

Jump to

Keyboard shortcuts

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