kubernetes/vendor/go.etcd.io/etcd/server/v3/lease/lessor.go

const NoLease

const MaxLeaseTTL

var v3_6

var forever

var defaultLeaseRevokeRate

var leaseCheckpointRate

var defaultLeaseCheckpointInterval

var maxLeaseCheckpointBatchSize

var defaultExpiredleaseRetryInterval

var ErrNotPrimary

var ErrLeaseNotFound

var ErrLeaseExists

var ErrLeaseTTLTooLarge

type TxnDelete

type RangeDeleter

type Checkpointer

type LeaseID

type Lessor

type lessor

type cluster

type LessorConfig

func NewLessor(lg *zap.Logger, b backend.Backend, cluster cluster, cfg LessorConfig) Lessor {}

func newLessor(lg *zap.Logger, b backend.Backend, cluster cluster, cfg LessorConfig) *lessor {}

// isPrimary indicates if this lessor is the primary lessor. The primary
// lessor manages lease expiration and renew.
//
// in etcd, raft leader is the primary. Thus there might be two primary
// leaders at the same time (raft allows concurrent leader but with different term)
// for at most a leader election timeout.
// The old primary leader cannot affect the correctness since its proposal has a
// smaller term and will not be committed.
//
// TODO: raft follower do not forward lease management proposals. There might be a
// very small window (within second normally which depends on go scheduling) that
// a raft follow is the primary between the raft leader demotion and lessor demotion.
// Usually this should not be a problem. Lease should not be that sensitive to timing.
func (le *lessor) isPrimary() bool {}

func (le *lessor) SetRangeDeleter(rd RangeDeleter) {}

func (le *lessor) SetCheckpointer(cp Checkpointer) {}

func (le *lessor) Grant(id LeaseID, ttl int64) (*Lease, error) {}

func (le *lessor) Revoke(id LeaseID) error {}

func (le *lessor) Checkpoint(id LeaseID, remainingTTL int64) error {}

func (le *lessor) shouldPersistCheckpoints() bool {}

func greaterOrEqual(first, second semver.Version) bool {}

// Renew renews an existing lease. If the given lease does not exist or
// has expired, an error will be returned.
func (le *lessor) Renew(id LeaseID) (int64, error) {}

func (le *lessor) Lookup(id LeaseID) *Lease {}

func (le *lessor) unsafeLeases() []*Lease {}

func (le *lessor) Leases() []*Lease {}

func (le *lessor) Promote(extend time.Duration) {}

type leasesByExpiry

func (le leasesByExpiry) Len() int           {}

func (le leasesByExpiry) Less(i, j int) bool {}

func (le leasesByExpiry) Swap(i, j int)      {}

func (le *lessor) Demote() {}

// Attach attaches items to the lease with given ID. When the lease
// expires, the attached items will be automatically removed.
// If the given lease does not exist, an error will be returned.
func (le *lessor) Attach(id LeaseID, items []LeaseItem) error {}

func (le *lessor) GetLease(item LeaseItem) LeaseID {}

// Detach detaches items from the lease with given ID.
// If the given lease does not exist, an error will be returned.
func (le *lessor) Detach(id LeaseID, items []LeaseItem) error {}

func (le *lessor) Recover(b backend.Backend, rd RangeDeleter) {}

func (le *lessor) ExpiredLeasesC() <-chan []*Lease {}

func (le *lessor) Stop() {}

func (le *lessor) runLoop() {}

// revokeExpiredLeases finds all leases past their expiry and sends them to expired channel for
// to be revoked.
func (le *lessor) revokeExpiredLeases() {}

// checkpointScheduledLeases finds all scheduled lease checkpoints that are due and
// submits them to the checkpointer to persist them to the consensus log.
func (le *lessor) checkpointScheduledLeases() {}

func (le *lessor) clearScheduledLeasesCheckpoints() {}

func (le *lessor) clearLeaseExpiredNotifier() {}

// expireExists returns true if expiry items exist.
// It pops only when expiry item exists.
// "next" is true, to indicate that it may exist in next attempt.
func (le *lessor) expireExists() (l *Lease, ok bool, next bool) {}

// findExpiredLeases loops leases in the leaseMap until reaching expired limit
// and returns the expired leases that needed to be revoked.
func (le *lessor) findExpiredLeases(limit int) []*Lease {}

func (le *lessor) scheduleCheckpointIfNeeded(lease *Lease) {}

func (le *lessor) findDueScheduledCheckpoints(checkpointLimit int) []*pb.LeaseCheckpoint {}

func (le *lessor) initAndRecover() {}

type Lease

func NewLease(id LeaseID, ttl int64) *Lease {}

func (l *Lease) expired() bool {}

func (l *Lease) persistTo(b backend.Backend) {}

// TTL returns the TTL of the Lease.
func (l *Lease) TTL() int64 {}

// SetLeaseItem sets the given lease item, this func is thread-safe
func (l *Lease) SetLeaseItem(item LeaseItem) {}

// RemainingTTL returns the last checkpointed remaining TTL of the lease.
// TODO(jpbetz): do not expose this utility method
func (l *Lease) RemainingTTL() int64 {}

// refresh refreshes the expiry of the lease.
func (l *Lease) refresh(extend time.Duration) {}

// forever sets the expiry of lease to be forever.
func (l *Lease) forever() {}

// Demoted returns true if the lease's expiry has been reset to forever.
func (l *Lease) Demoted() bool {}

// Keys returns all the keys attached to the lease.
func (l *Lease) Keys() []string {}

// Remaining returns the remaining time of the lease.
func (l *Lease) Remaining() time.Duration {}

type LeaseItem

func int64ToBytes(n int64) []byte {}

func bytesToLeaseID(bytes []byte) int64 {}

func unsafeGetAllLeases(tx backend.ReadTx) []*leasepb.Lease {}

type FakeLessor

func (fl *FakeLessor) SetRangeDeleter(dr RangeDeleter) {}

func (fl *FakeLessor) SetCheckpointer(cp Checkpointer) {}

func (fl *FakeLessor) Grant(id LeaseID, ttl int64) (*Lease, error) {}

func (fl *FakeLessor) Revoke(id LeaseID) error {}

func (fl *FakeLessor) Checkpoint(id LeaseID, remainingTTL int64) error {}

func (fl *FakeLessor) Attach(id LeaseID, items []LeaseItem) error {}

func (fl *FakeLessor) GetLease(item LeaseItem) LeaseID            {}

func (fl *FakeLessor) Detach(id LeaseID, items []LeaseItem) error {}

func (fl *FakeLessor) Promote(extend time.Duration) {}

func (fl *FakeLessor) Demote() {}

func (fl *FakeLessor) Renew(id LeaseID) (int64, error) {}

func (fl *FakeLessor) Lookup(id LeaseID) *Lease {}

func (fl *FakeLessor) Leases() []*Lease {}

func (fl *FakeLessor) ExpiredLeasesC() <-chan []*Lease {}

func (fl *FakeLessor) Recover(b backend.Backend, rd RangeDeleter) {}

func (fl *FakeLessor) Stop() {}

type FakeTxnDelete

func (ftd *FakeTxnDelete) DeleteRange(key, end []byte) (n, rev int64) {}

func (ftd *FakeTxnDelete) End()                                       {}