fencing

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package fencing defines resource leases that issue fencing tokens.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLeaseHeld  = errors.New("fencing resource lease is held")
	ErrStaleGrant = errors.New("stale fencing grant")
)

Functions

func IsSerializationFailure

func IsSerializationFailure(err error) bool

IsSerializationFailure reports the PostgreSQL retry class without coupling callers to one concrete driver error type.

Types

type Guarantee

type Guarantee string

Guarantee states the persistence guarantee of a provider.

const (
	GuaranteeLocalAdvisory    Guarantee = "local_advisory"
	GuaranteeDurableMonotonic Guarantee = "durable_monotonic"
)

type InMemoryProvider

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

InMemoryProvider provides local advisory serialization only.

func NewInMemoryProvider

func NewInMemoryProvider() *InMemoryProvider

func (*InMemoryProvider) Acquire

func (provider *InMemoryProvider) Acquire(ctx context.Context, request Request) (Lease, error)

func (*InMemoryProvider) Guarantee

func (*InMemoryProvider) Guarantee() Guarantee

type Lease

type Lease interface {
	Grant() invocation.FencingGrant
	Renew(context.Context, time.Duration) error
	Release(context.Context) error
}

Lease is one acquired grant.

type PostgresProvider

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

PostgresProvider issues durable monotonic tokens from V2 migration tables.

func NewPostgresProvider

func NewPostgresProvider(db *sql.DB) (*PostgresProvider, error)

func (*PostgresProvider) Acquire

func (provider *PostgresProvider) Acquire(ctx context.Context, request Request) (Lease, error)

func (*PostgresProvider) Guarantee

func (*PostgresProvider) Guarantee() Guarantee

type Provider

type Provider interface {
	Guarantee() Guarantee
	Acquire(context.Context, Request) (Lease, error)
}

Provider issues grants and reports their persistence guarantee.

type Request

type Request struct {
	Authority string
	Resource  string
	Holder    string
	TTL       time.Duration
}

Request identifies one resource lease.

Jump to

Keyboard shortcuts

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