lease

package
v0.2.15 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

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