dbleaser

package
v0.390.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseLeaser

type DatabaseLeaser struct {
	*libdal.Handle[DatabaseLeaser]
	// contains filtered or unexported fields
}

func NewDatabaseLeaser

func NewDatabaseLeaser(conn libdal.Connection) *DatabaseLeaser

func (*DatabaseLeaser) AcquireLease

func (d *DatabaseLeaser) AcquireLease(ctx context.Context, key leases.Key, ttl time.Duration, metadata optional.Option[any]) (leases.Lease, context.Context, error)

AcquireLease acquires a lease for the given key.

Will return leases.ErrConflict (not libdal.ErrConflict) if the lease is already held by another controller.

The returned context will be cancelled when the lease fails to renew.

func (*DatabaseLeaser) ExpireLeases

func (d *DatabaseLeaser) ExpireLeases(ctx context.Context) error

ExpireLeases expires (deletes) all leases that have expired.

func (*DatabaseLeaser) GetLeaseInfo

func (d *DatabaseLeaser) GetLeaseInfo(ctx context.Context, key leases.Key, metadata any) (expiry time.Time, err error)

GetLeaseInfo returns the metadata and expiry time for the lease with the given key.

metadata should be a pointer to the type that metadata should be unmarshaled into.

func (*DatabaseLeaser) NewLease

func (d *DatabaseLeaser) NewLease(ctx context.Context, key leases.Key, idempotencyKey uuid.UUID, ttl time.Duration) (*Lease, context.Context)

NewLease creates a new lease for the given key.

type Lease

type Lease struct {
	// contains filtered or unexported fields
}

Lease represents a lease that is held by a controller.

func (*Lease) Release

func (l *Lease) Release() error

func (*Lease) String

func (l *Lease) String() string

Directories

Path Synopsis
internal
sql

Jump to

Keyboard shortcuts

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