Documentation
¶
Overview ¶
Package memory provides in-memory implementations of the persistence ports defined in internal/ports. It is the canonical backend used by tests; production code should use the SQLite or Postgres backends.
Registers itself with the top-level store factory under the "memory" scheme. Per Mnemos ADR 0001 §3, ?namespace= is accepted but produces independent state per Open — there is no shared process-wide map, so each call to store.Open("memory://...") returns a fresh, empty backend regardless of namespace.
Index ¶
- type Conn
- type EntityStateRepository
- func (r *EntityStateRepository) Count(_ context.Context, adapterName string) (int64, error)
- func (r *EntityStateRepository) DeleteOlderThan(_ context.Context, cutoff time.Time, adapterName string) error
- func (r *EntityStateRepository) Ingest(_ context.Context, adapterName string, state chronos.EntityState) error
- func (r *EntityStateRepository) ListByEntity(_ context.Context, entityID uuid.UUID) ([]chronos.EntityState, error)
- func (r *EntityStateRepository) ListByScope(_ context.Context, scopeID uuid.UUID) ([]chronos.EntityState, error)
- func (r *EntityStateRepository) ListScopes(_ context.Context) ([]uuid.UUID, error)
- func (r *EntityStateRepository) Save(_ context.Context, adapterName string, states []chronos.EntityState) error
- type SignalRepository
- func (r *SignalRepository) Count(_ context.Context, filter ports.SignalFilter) (int64, error)
- func (r *SignalRepository) Get(_ context.Context, id uuid.UUID) (domain.Signal, error)
- func (r *SignalRepository) List(_ context.Context, filter ports.SignalFilter) ([]domain.Signal, error)
- func (r *SignalRepository) Save(_ context.Context, sig domain.Signal) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
EntityStates *EntityStateRepository
Signals *SignalRepository
// contains filtered or unexported fields
}
Conn bundles the in-memory repositories. The zero value is unusable; use New.
type EntityStateRepository ¶
type EntityStateRepository struct {
// contains filtered or unexported fields
}
EntityStateRepository implements ports.EntityStateRepository in memory.
func (*EntityStateRepository) Count ¶
Count returns the total number of states recorded by adapterName.
func (*EntityStateRepository) DeleteOlderThan ¶
func (r *EntityStateRepository) DeleteOlderThan(_ context.Context, cutoff time.Time, adapterName string) error
DeleteOlderThan removes states observed before cutoff for the named adapter.
func (*EntityStateRepository) Ingest ¶
func (r *EntityStateRepository) Ingest(_ context.Context, adapterName string, state chronos.EntityState) error
Ingest persists a single observation.
func (*EntityStateRepository) ListByEntity ¶
func (r *EntityStateRepository) ListByEntity(_ context.Context, entityID uuid.UUID) ([]chronos.EntityState, error)
ListByEntity scans all scopes for observations of entityID, most recent first.
func (*EntityStateRepository) ListByScope ¶
func (r *EntityStateRepository) ListByScope(_ context.Context, scopeID uuid.UUID) ([]chronos.EntityState, error)
ListByScope returns a defensive copy of all states recorded under scopeID, most recent first.
func (*EntityStateRepository) ListScopes ¶
ListScopes returns the distinct ScopeIDs that have at least one observation. Order is unspecified. The scheduler uses this to know which scopes to detect over.
func (*EntityStateRepository) Save ¶
func (r *EntityStateRepository) Save(_ context.Context, adapterName string, states []chronos.EntityState) error
Save persists a batch of observations.
type SignalRepository ¶
type SignalRepository struct {
// contains filtered or unexported fields
}
SignalRepository implements ports.SignalRepository in memory.
func (*SignalRepository) Count ¶
func (r *SignalRepository) Count(_ context.Context, filter ports.SignalFilter) (int64, error)
Count returns the number of signals matching filter.
func (*SignalRepository) List ¶
func (r *SignalRepository) List(_ context.Context, filter ports.SignalFilter) ([]domain.Signal, error)
List returns signals matching the filter, ordered detected-at desc then confidence desc.