Documentation
¶
Overview ¶
Package memory holds the in-memory adapters: a full implementation used by the test suite, and a template for custom adapters.
Index ¶
- type Bus
- type Kv
- func (k *Kv) Del(_ context.Context, key string) error
- func (k *Kv) DelIfValue(_ context.Context, key, expected string) (bool, error)
- func (k *Kv) Get(_ context.Context, key string) (string, bool, error)
- func (k *Kv) Incr(_ context.Context, key string) (int64, error)
- func (k *Kv) IncrWithExpiry(_ context.Context, key string, ttl time.Duration) (int64, error)
- func (k *Kv) Set(_ context.Context, key, value string, opts ports.SetOptions) (bool, error)
- func (k *Kv) SetIfValue(_ context.Context, key, expected, value string, ttl time.Duration) (bool, error)
- type Queue
- func (q *Queue) Cancel(_ context.Context, key string) error
- func (q *Queue) Delays() []time.Duration
- func (q *Queue) Drain(ctx context.Context, handler func(ctx context.Context, job ports.RunJob) error) (int, error)
- func (q *Queue) Enqueue(_ context.Context, job ports.RunJob, opts *ports.EnqueueOptions) error
- func (q *Queue) Find(_ context.Context, runID string) (*ports.QueuedJob, error)
- func (q *Queue) Items() []ports.RunJob
- func (q *Queue) Keys() []string
- func (q *Queue) Len() int
- func (q *Queue) Priorities() []int
- func (q *Queue) Shift() (ports.RunJob, bool)
- func (q *Queue) Stats(_ context.Context) (ports.QueueStats, error)
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
Bus is a synchronous in-memory bus. Publishes are delivered to subscribers in order, on the publisher's goroutine.
func (*Bus) Published ¶
func (b *Bus) Published() []ports.AgentEvent
Published is every event ever published, in order.
func (*Bus) Subscribers ¶
Subscribers counts live subscriptions on a thread, so a test can prove a stream cleaned up after itself.
type Kv ¶
type Kv struct {
// contains filtered or unexported fields
}
Kv is an in-memory Kv for tests and local prototyping. Expiry is enforced lazily on read; Incr holds the lock, so concurrent callers can never collide on the same counter (§3.4).
func (*Kv) DelIfValue ¶ added in v0.3.0
func (*Kv) IncrWithExpiry ¶ added in v0.3.0
type Queue ¶
type Queue struct {
// MaxDepth refuses a fresh dispatch past this many waiting jobs; zero is
// unbounded.
MaxDepth int
// contains filtered or unexported fields
}
Queue is an in-memory queue with a Drain helper: tests process jobs exactly like the worker would. It honours the port's keys (a duplicate key is refused, Cancel drops it) and an optional depth cap, so the engine's behaviour around both can be tested without a database.
func (*Queue) Delays ¶
Delays are the delivery delays requested per enqueue, index-aligned with Items.
func (*Queue) Drain ¶
func (q *Queue) Drain(ctx context.Context, handler func(ctx context.Context, job ports.RunJob) error) (int, error)
Drain hands every waiting job to the handler, in order, including jobs the handler enqueues. Returns how many were handled.
func (*Queue) Keys ¶ added in v0.3.0
Keys are the dedupe keys per enqueue, index-aligned with Items.
func (*Queue) Priorities ¶ added in v0.3.0
Priorities are the priorities per enqueue, index-aligned with Items.
type Storage ¶
type Storage struct {
// LastContext is the StorageContext of the most recent call, so a test
// can prove the run state reached the adapter (§2.10).
LastContext ports.StorageContext
// Contexts records every StorageContext seen, in order.
Contexts []ports.StorageContext
// contains filtered or unexported fields
}
Storage is a full in-memory Storage: tests, demos, and a template for custom adapters.
func (*Storage) Events ¶
func (s *Storage) Events() ports.EventStore
func (*Storage) MessageRows ¶
func (s *Storage) MessageRows(threadID string) []ports.MessageDTO
MessageRows is the raw message list for a thread, for tests.
func (*Storage) Messages ¶
func (s *Storage) Messages() ports.MessageStore
func (*Storage) Threads ¶
func (s *Storage) Threads() ports.ThreadStore
func (*Storage) Usage ¶
func (s *Storage) Usage() ports.UsageStore