memory

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

Backend is an in-memory ownership store for tests and single-process use.

func New

func New(opts ...Option) *Backend

New creates a memory backend.

func (*Backend) AbortTransfer

func (b *Backend) AbortTransfer(ctx context.Context, req shiftlock.AbortRequest) (*shiftlock.ClaimRecord, error)

func (*Backend) AcquireClaim

func (b *Backend) AcquireClaim(ctx context.Context, req shiftlock.AcquireRequest) (*shiftlock.ClaimRecord, error)

func (*Backend) Capabilities

func (b *Backend) Capabilities() shiftlock.Capabilities

Capabilities implements shiftlock.Capabler.

func (*Backend) Close

func (b *Backend) Close() error

func (*Backend) CommitTransfer

func (b *Backend) CommitTransfer(ctx context.Context, req shiftlock.CommitRequest) (*shiftlock.ClaimRecord, error)

func (*Backend) CrashOnCommit

func (b *Backend) CrashOnCommit(v bool)

CrashOnCommit simulates a crash after prepare but before durable commit visibility.

func (*Backend) FailNext

func (b *Backend) FailNext(err error)

FailNext causes the next mutating call to return err.

func (*Backend) FailPrepareAt

func (b *Backend) FailPrepareAt(n int)

FailPrepareAt fails the n-th PrepareTransfer call (1-based) with ErrBackend. Useful for multi-claim partial Transfer tests. Pass 0 to disable.

func (*Backend) ForceExpire

func (b *Backend) ForceExpire(claimName string)

ForceExpire expires a claim immediately (test helper).

func (*Backend) ForceSetToken

func (b *Backend) ForceSetToken(claimName string, tok shiftlock.FencingToken)

ForceSetToken sets the claim token for overflow tests (creates unowned claim).

func (*Backend) GetClaim

func (b *Backend) GetClaim(ctx context.Context, claimName string) (*shiftlock.ClaimRecord, error)

func (*Backend) GetGeneration

func (b *Backend) GetGeneration(ctx context.Context, generationID string) (*shiftlock.Generation, error)

func (*Backend) PrepareTransfer

func (b *Backend) PrepareTransfer(ctx context.Context, req shiftlock.TransferRequest) (*shiftlock.ClaimRecord, error)

func (*Backend) RegisterGeneration

func (b *Backend) RegisterGeneration(ctx context.Context, gen shiftlock.Generation) error

func (*Backend) ReleaseClaim

func (b *Backend) ReleaseClaim(ctx context.Context, req shiftlock.ReleaseRequest) error

func (*Backend) RenewClaim

func (*Backend) SetDelay

func (b *Backend) SetDelay(d time.Duration)

SetDelay adds artificial delay to mutating calls.

func (*Backend) SetPartition

func (b *Backend) SetPartition(on bool)

SetPartition toggles partition mode (mutations fail).

func (*Backend) Snapshot

func (b *Backend) Snapshot() map[string]shiftlock.ClaimRecord

Snapshot returns a copy of all claims (test helper).

func (*Backend) UpdateGeneration

func (b *Backend) UpdateGeneration(ctx context.Context, gen shiftlock.Generation) error

func (*Backend) WatchClaim

func (b *Backend) WatchClaim(ctx context.Context, claimName string) (<-chan shiftlock.ClaimEvent, error)

type Option

type Option func(*Backend)

Option configures the memory backend.

func WithClock

func WithClock(c shiftlock.Clock) Option

WithClock sets a custom clock.

func WithPartitionSimulation

func WithPartitionSimulation() Option

WithPartitionSimulation enables network partition: when partitioned, mutating calls return ErrBackend.

Jump to

Keyboard shortcuts

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