memory

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package memory provides a first-class in-memory implementation of the persistence port interfaces. The repository stores all data in maps and slices, supports the same pagination, filtering, and ordering semantics as the SQLite adapter, and is safe for concurrent use.

This adapter is not a mock or test-only fake — it is a fully functional, behaviorally correct implementation of the driven port contract. Its existence keeps the port abstraction honest: every driven port method must be implementable without importing adapter-specific types (SQLite handles, query builders, etc.). See docs/developer/architecture.md §7 for the full rationale.

Primary uses:

  • Unit-testing the core without database I/O.
  • Validating that the driven port interface is a real abstraction, not a thin wrapper over the SQLite adapter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

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

Repository is an in-memory implementation of all persistence port interfaces. It is safe for concurrent use.

func NewRepository

func NewRepository() *Repository

NewRepository creates an empty in-memory repository.

func (*Repository) AppendHistory

func (r *Repository) AppendHistory(_ context.Context, entry history.Entry) (int64, error)

func (*Repository) ClearAllData

func (r *Repository) ClearAllData(_ context.Context) error

func (*Repository) CountDeletedRatio

func (r *Repository) CountDeletedRatio(_ context.Context) (total, deleted int, err error)

func (*Repository) CountHistory

func (r *Repository) CountHistory(_ context.Context, issueID domain.ID) (int, error)

func (*Repository) CountVirtualLabelsInTable

func (r *Repository) CountVirtualLabelsInTable(_ context.Context) (int, error)

CountVirtualLabelsInTable always returns 0 in the in-memory adapter because it never stores virtual labels in the labels backing structure — they are always handled correctly.

func (*Repository) CreateClaim

func (r *Repository) CreateClaim(_ context.Context, c domain.Claim) error

func (*Repository) CreateComment

func (r *Repository) CreateComment(_ context.Context, n domain.Comment) (int64, error)

func (*Repository) CreateIssue

func (r *Repository) CreateIssue(_ context.Context, t domain.Issue) error

func (*Repository) CreateRelationship

func (r *Repository) CreateRelationship(_ context.Context, rel domain.Relationship) (bool, error)

func (*Repository) DeleteExpiredClaims added in v0.2.0

func (r *Repository) DeleteExpiredClaims(_ context.Context, now time.Time) (int, error)

DeleteExpiredClaims removes all claim rows whose stale-at timestamp is on or before now. Returns the count of deleted rows. Active claims are preserved.

func (*Repository) DeleteRelationship

func (r *Repository) DeleteRelationship(_ context.Context, sourceID, targetID domain.ID, relType domain.RelationType) (bool, error)

func (*Repository) GC

func (r *Repository) GC(_ context.Context, includeClosed bool) (int, int, error)

func (*Repository) GetAncestorStatuses

func (r *Repository) GetAncestorStatuses(_ context.Context, id domain.ID) ([]domain.AncestorStatus, error)

func (*Repository) GetBlockerStatuses

func (r *Repository) GetBlockerStatuses(_ context.Context, issueID domain.ID) ([]domain.BlockerStatus, error)

func (*Repository) GetChildStatuses

func (r *Repository) GetChildStatuses(_ context.Context, epicID domain.ID) ([]domain.ChildStatus, error)

func (*Repository) GetClaimByID

func (r *Repository) GetClaimByID(_ context.Context, claimID string) (domain.Claim, error)

func (*Repository) GetClaimByIssue

func (r *Repository) GetClaimByIssue(_ context.Context, issueID domain.ID) (domain.Claim, error)

func (*Repository) GetComment

func (r *Repository) GetComment(_ context.Context, id int64) (domain.Comment, error)

func (*Repository) GetDescendants

func (r *Repository) GetDescendants(_ context.Context, epicID domain.ID) ([]domain.DescendantInfo, error)

func (*Repository) GetIssue

func (r *Repository) GetIssue(_ context.Context, id domain.ID, includeDeleted bool) (domain.Issue, error)

func (*Repository) GetIssueByIdempotencyKey

func (r *Repository) GetIssueByIdempotencyKey(_ context.Context, key string) (domain.Issue, error)

func (*Repository) GetIssueSummary

func (r *Repository) GetIssueSummary(_ context.Context) (driven.IssueSummary, error)

func (*Repository) GetLatestHistory

func (r *Repository) GetLatestHistory(_ context.Context, issueID domain.ID) (history.Entry, error)

func (*Repository) GetParentID

func (r *Repository) GetParentID(_ context.Context, id domain.ID) (domain.ID, error)

func (*Repository) GetPrefix

func (r *Repository) GetPrefix(_ context.Context) (string, error)

func (*Repository) GetSchemaVersion added in v0.2.0

func (r *Repository) GetSchemaVersion(_ context.Context) (int, error)

GetSchemaVersion always returns 2 in the in-memory adapter because the in-memory store is always freshly initialized at v2. There is no on-disk v1 schema to migrate.

func (*Repository) HasChildren

func (r *Repository) HasChildren(_ context.Context, epicID domain.ID) (bool, error)

func (*Repository) InitDatabase

func (r *Repository) InitDatabase(_ context.Context, prefix string) error

func (*Repository) IntegrityCheck

func (r *Repository) IntegrityCheck(_ context.Context) error

func (*Repository) InvalidateClaim

func (r *Repository) InvalidateClaim(_ context.Context, claimID string) error

func (*Repository) IssueIDExists

func (r *Repository) IssueIDExists(_ context.Context, id domain.ID) (bool, error)

func (*Repository) ListActiveClaims

func (r *Repository) ListActiveClaims(_ context.Context, now time.Time) ([]domain.Claim, error)

func (*Repository) ListComments

func (r *Repository) ListComments(_ context.Context, issueID domain.ID, filter driven.CommentFilter, limit int) ([]domain.Comment, bool, error)

func (*Repository) ListDistinctLabels

func (r *Repository) ListDistinctLabels(_ context.Context) ([]domain.Label, error)

func (*Repository) ListHistory

func (r *Repository) ListHistory(_ context.Context, issueID domain.ID, filter driven.HistoryFilter, limit int) ([]history.Entry, bool, error)

func (*Repository) ListIssues

func (r *Repository) ListIssues(_ context.Context, filter driven.IssueFilter, orderBy driven.IssueOrderBy, direction driven.SortDirection, limit int) ([]driven.IssueListItem, bool, error)

func (*Repository) ListRelationships

func (r *Repository) ListRelationships(_ context.Context, issueID domain.ID) ([]domain.Relationship, error)

func (*Repository) ListStaleClaims

func (r *Repository) ListStaleClaims(_ context.Context, now time.Time) ([]domain.Claim, error)

func (*Repository) RebuildFTS

func (r *Repository) RebuildFTS(_ context.Context) error

func (*Repository) RestoreClaimRaw

func (r *Repository) RestoreClaimRaw(_ context.Context, _ string, _ domain.BackupClaimRecord) error

func (*Repository) RestoreCommentRaw

func (r *Repository) RestoreCommentRaw(_ context.Context, _ string, _ domain.BackupCommentRecord) error

func (*Repository) RestoreHistoryRaw

func (r *Repository) RestoreHistoryRaw(_ context.Context, _ string, _ domain.BackupHistoryRecord) error

func (*Repository) RestoreIssueRaw

func (r *Repository) RestoreIssueRaw(_ context.Context, rec domain.BackupIssueRecord) error

func (*Repository) RestoreLabelRaw

func (r *Repository) RestoreLabelRaw(_ context.Context, _ string, _ domain.BackupLabelRecord) error

func (*Repository) RestoreRelationshipRaw

func (r *Repository) RestoreRelationshipRaw(_ context.Context, _ string, _ domain.BackupRelationshipRecord) error

func (*Repository) SearchComments

func (r *Repository) SearchComments(_ context.Context, query string, filter driven.CommentFilter, limit int) ([]domain.Comment, bool, error)

func (*Repository) SearchIssues

func (r *Repository) SearchIssues(_ context.Context, query string, filter driven.IssueFilter, orderBy driven.IssueOrderBy, direction driven.SortDirection, limit int) ([]driven.IssueListItem, bool, error)

func (*Repository) SetSchemaVersion added in v0.2.0

func (r *Repository) SetSchemaVersion(_ context.Context, _ int) error

SetSchemaVersion is a no-op in the in-memory adapter. The in-memory store always operates at v2 and has no on-disk schema to migrate; this method exists to satisfy the DatabaseRepository interface.

func (*Repository) UpdateClaimStaleAt

func (r *Repository) UpdateClaimStaleAt(_ context.Context, claimID string, staleAt time.Time) error

func (*Repository) UpdateIssue

func (r *Repository) UpdateIssue(_ context.Context, t domain.Issue) error

type Transactor

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

Transactor implements driven.Transactor using the in-memory repository. Since the repository is inherently atomic (protected by mutex), the transactor simply delegates to it.

func NewTransactor

func NewTransactor(repo *Repository) *Transactor

NewTransactor creates a Transactor backed by the given repository.

func (*Transactor) Vacuum

func (t *Transactor) Vacuum(_ context.Context) error

Vacuum is a no-op for the in-memory adapter — there is no disk to reclaim.

func (*Transactor) WithReadTransaction

func (t *Transactor) WithReadTransaction(_ context.Context, fn func(uow driven.UnitOfWork) error) error

WithReadTransaction executes fn with a read-only unit of work.

func (*Transactor) WithTransaction

func (t *Transactor) WithTransaction(_ context.Context, fn func(uow driven.UnitOfWork) error) error

WithTransaction executes fn with the repository as the unit of work. The in-memory adapter has no real transaction to commit/rollback.

Jump to

Keyboard shortcuts

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