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 ¶
- type Store
- func (s *Store) AcquireLease(ctx context.Context, target, owner string, ttl time.Duration) (threadstore.Lease, error)
- func (s *Store) Finalize(_ context.Context, req threadstore.FinalizeRequest) error
- func (s *Store) ReleaseLease(_ context.Context, lease threadstore.Lease) error
- func (s *Store) RenewLease(_ context.Context, lease threadstore.Lease, ttl time.Duration) error
- func (s *Store) Resolve(_ context.Context, q threadstore.Query) (*threadstore.Record, error)
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 (*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 ¶
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 ¶
RenewLease extends a lease if the caller still owns the matching token.
func (*Store) Resolve ¶
func (s *Store) Resolve(_ context.Context, q threadstore.Query) (*threadstore.Record, error)
Resolve looks up a record by internal ID or by thread key. Missing records resolve to (nil, nil); archived records require q.IncludeArchived.