lessor

package
v0.0.0-...-d3da680 Latest Latest
Warning

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

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

Documentation

Overview

Package lessor defines common lessor interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(id string, factory func(ctx context.Context) (Lessor, error))

Register registers a lessor implementation.

Preferably IDs should match the corresponding database.Database implementations, since by default if the TQ uses a database "<X>" it will use the lessor "<X>" as well. But there may be IDs that are no associated with any database implementation (e.g. a Redis-based lessor). Such lessors need an explicit opt-in to be used.

Must be called during init time.

Types

type Lessor

type Lessor interface {
	// WithLease acquires the lease and executes WithLeaseCB.
	//
	// The obtained lease duration may be shorter than requested.
	// The obtained lease may be only for some parts of the desired Partition.
	//
	// The given `sectionID` identifies a transactionally updated object that
	// actually stores records about the currently leased sub-partitions of
	// `part`. Each such section is independent of another. In other words, if
	// some range of keys is covered by two different sections, it may be leased
	// to two different callers at the same time, there's no synchronization in
	// such case.
	WithLease(ctx context.Context, sectionID string, part *partition.Partition, dur time.Duration, cb WithLeaseCB) error
}

Lessor abstracts out different implementations aimed to prevent concurrent processing of the same range of Reminders.

Lessors are used by the distributed sweep implementation.

func Get

func Get(ctx context.Context, id string) (Lessor, error)

Get returns a particular Lessor implementation given its ID.

type WithLeaseCB

type WithLeaseCB func(context.Context, partition.SortedPartitions)

WithLeaseCB executes with active lease on the provided SortedPartitions.

SortedPartitions may be empty slice, meaning there were existing active leases cumulatively covering the entire desired partition. Context deadline is set before the lease expires.

Jump to

Keyboard shortcuts

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