Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Coordinator ¶
type Coordinator[P any] struct { // contains filtered or unexported fields }
Coordinator assigns a single leader for the rest to follow.
P is the protocol that the leader and followers must implement. Callers of Get() will receive a P, abstracting away whether they are interacting with a leader or a follower.
func NewCoordinator ¶
func NewCoordinator[P any](ctx context.Context, advertise *url.URL, key leases.Key, leaser leases.Leaser, leaseTTL time.Duration, leaderFactory LeaderFactory[P], followerFactory FollowerFactory[P]) *Coordinator[P]
func (*Coordinator[P]) Get ¶
func (c *Coordinator[P]) Get() (leaderOrFollower P, err error)
Get returns either a leader or follower
type FollowerFactory ¶
FollowerFactory is a function that is called whenever we follow a new leader.
If the new leader has the same url as the previous leader, the existing follower will be used.
Click to show internal directories.
Click to hide internal directories.