memory

package
v1.1.2 Latest Latest
Warning

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

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

Documentation

Overview

Package memory provides a concurrency-safe, in-memory implementation of threadstore.Store.

A Store is suitable for tests, local tools, and single-process hosts. Its records and leases disappear when the process exits, so hosts that require durable or cross-process thread coordination should provide another threadstore.Store implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store is an in-memory implementation of threadstore.Store. It is useful for tests, local CLIs, demos, and single-process hosts that do not need thread state to survive process restarts. Production services that run multiple processes should provide a durable/centralized store instead.

Store coordinates callers within one process. It does not provide durable storage or coordination across processes.

func NewStore

func NewStore() *Store

NewStore constructs an empty in-memory threadstore.Store.

func (*Store) AcquireLease

func (s *Store) AcquireLease(ctx context.Context, target, owner string, ttl time.Duration) (threadstore.Lease, error)

AcquireLease obtains or renews exclusive use of target for owner until ttl elapses. A valid lease held by a different owner yields a BusyError.

func (*Store) Finalize

func (s *Store) Finalize(_ context.Context, req threadstore.FinalizeRequest) error

Finalize persists the post-run record and performs archive/rebind operations after validating all held leases.

func (*Store) ReleaseLease

func (s *Store) ReleaseLease(_ context.Context, lease threadstore.Lease) error

ReleaseLease releases a lease when the caller owns the matching token. Lost or already-expired leases are ignored to keep cleanup idempotent.

func (*Store) RenewLease

func (s *Store) RenewLease(_ context.Context, lease threadstore.Lease, ttl time.Duration) error

RenewLease extends a lease if the caller still owns the matching token.

func (*Store) Resolve

Resolve looks up a record by internal ID or by thread key. Missing records resolve to (nil, nil); archived records require q.IncludeArchived.

Jump to

Keyboard shortcuts

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