luci: go.chromium.org/luci/server/tq/internal/lessor Index | Files

package lessor

import "go.chromium.org/luci/server/tq/internal/lessor"

Package lessor defines common lessor interface.

Index

Package Files

lessor.go

func Register Uses

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.

type Lessor Uses

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 Uses

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

Get returns a particular Lessor implementation given its ID.

type WithLeaseCB Uses

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.

Package lessor imports 5 packages (graph) and is imported by 2 packages. Updated 2020-09-30. Refresh now. Tools for package owners.