lease

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 4 Imported by: 1 module, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ActionTypeExtend = iota
	ActionTypeRefresh
	ActionTypeRenew
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Hooks

type Hooks interface {
	OnRefresh(fn func())
	OnExtend(fn func())
	OnRenew(fn func())
	OnExpired(fn func())
	OnCancel(fn func())
}

type Lease

type Lease interface {
	ID() string
	Start()
	Refresh(duraton time.Duration) bool
	Extend(duraton time.Duration) bool
	Renew(expiresAt time.Time) bool
	Cancel()
	Expired() bool
	ExpiresAt() time.Time
	Hooks
}

func New

func New(id string, duration time.Duration, opts ...LeaseOption) Lease

type LeaseOption

type LeaseOption func(*lease)

func OnCancel

func OnCancel(fn func()) LeaseOption

func OnExpired

func OnExpired(fn func()) LeaseOption

func OnExtend

func OnExtend(fn func()) LeaseOption

func OnRefresh

func OnRefresh(fn func()) LeaseOption

func OnRenew

func OnRenew(fn func()) LeaseOption

func Once

func Once() LeaseOption

func UseWallTime

func UseWallTime() LeaseOption

func WithLogger

func WithLogger(logger log.Logger) LeaseOption

Jump to

Keyboard shortcuts

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