Documentation ¶
Index ¶
- Constants
- Variables
- type Election
- type Elector
- type Kube
- func (k Kube) GetLeader(ctx context.Context, r dsync.Resource) (string, error)
- func (k Kube) GetLease(ctx context.Context, namespace, name string) (*v1.Lease, error)
- func (k Kube) GetLock(ctx context.Context, r dsync.Resource, requester string) (*Lock, error)
- func (k Kube) NewElection(ctx context.Context, r dsync.Resource, candidate string, ...) (*Election, error)
- type KubeOpt
- type LeaderCallbacks
- type LeaseClient
- type Lock
- type LockOption
Constants ¶
View Source
const ( DefaultLockTTL = time.Second * 0 // unlimited DefaultRetryInterval = time.Second )
Variables ¶
View Source
var ( ErrNoLeader = dsync.ErrNoLeader ErrNotFound = dsync.ErrNotFound ErrAlreadyLocked = dsync.ErrAlreadyLocked ErrLeaseNotFound = errors.New("resource lease not found") ErrUpdateLeaseFail = errors.New("resource lease update failed") ErrCreateLeaseFail = errors.New("resource lease create failed") ErrNotLockHolder = dsync.ErrNotLockHolder ErrNotLocked = dsync.ErrNotLocked )
Functions ¶
This section is empty.
Types ¶
type Election ¶
type Election struct {
// contains filtered or unexported fields
}
func NewElection ¶
func NewElection( ctx context.Context, client LeaseClient, r dsync.Resource, candidate string, callbacks ...LeaderCallbacks, ) (*Election, error)
func (*Election) WhenElected ¶
type Elector ¶
type Elector struct {
// contains filtered or unexported fields
}
func NewLeaderElector ¶
func NewLeaderElector( ctx context.Context, client LeaseClient, r dsync.Resource, candidate string, callbacks ...LeaderCallbacks, ) (*Elector, error)
func (Elector) GetLeader ¶
GetLeader will return the current leader if the election has not completed it returns empty string
type Kube ¶
type Kube struct {
// contains filtered or unexported fields
}
type KubeOpt ¶
type KubeOpt func(k *Kube)
func KubeWithCS ¶
func KubeWithCS(cs kubernetes.Interface) KubeOpt
func KubeWithKCP ¶
func KubeWithLockTTL ¶
type LeaderCallbacks ¶
type LeaderCallbacks struct { // OnStartedLeading is called when a LeaderElector client starts leading OnStartedLeading func(context.Context) // OnStoppedLeading is called when a LeaderElector client stops leading OnStoppedLeading func() // OnNewLeader is called when the client observes a leader that is // not the previously observed leader. This includes the first observed // leader when the client starts. OnNewLeader func(identity string) }
LeaderCallbacks callbacks that are triggered during certain lifecycle events This is copied directly out of k8s.io/client-go/tools/leaderelection
type LeaseClient ¶
type LeaseClient = coordinationv1client.LeasesGetter
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
type LockOption ¶
type LockOption func(*Lock)
func LockWithRetryInterval ¶
func LockWithRetryInterval(d time.Duration) LockOption
func LockWithTTL ¶
func LockWithTTL(d time.Duration) LockOption
Click to show internal directories.
Click to hide internal directories.