Documentation
¶
Overview ¶
Package memory is an in-memory metadata.Repository used as a test double. It mirrors the pgx implementation's observable semantics — live-only reads, soft delete, tag containment, keyset paging by id, reserved-key preservation on replace — so the layers above can be exercised without Postgres. It is not a deployment target.
Index ¶
- type Repo
- func (r *Repo) ClaimIdempotencyKey(ctx context.Context, key string) (bool, *metadata.IdempotencyRecord, error)
- func (r *Repo) ClaimJob(ctx context.Context) (*metadata.Job, error)
- func (r *Repo) CountPendingJobs(context.Context) (int, error)
- func (r *Repo) Create(ctx context.Context, f *metadata.File) error
- func (r *Repo) CreateForKey(ctx context.Context, f *metadata.File, key string) error
- func (r *Repo) CreateJob(ctx context.Context, j *metadata.Job) (bool, string, error)
- func (r *Repo) Delete(ctx context.Context, id string) error
- func (r *Repo) FinishJob(ctx context.Context, id string, attempt int, res metadata.JobResult) error
- func (r *Repo) Get(ctx context.Context, id string) (*metadata.File, error)
- func (r *Repo) GetJob(ctx context.Context, id string) (*metadata.Job, error)
- func (r *Repo) HeartbeatJob(ctx context.Context, id string, attempt, done, total int) (bool, error)
- func (r *Repo) List(ctx context.Context, filter metadata.ListFilter) ([]*metadata.File, error)
- func (r *Repo) ListDeleted(_ context.Context, limit int) ([]*metadata.File, error)
- func (r *Repo) ParkJob(ctx context.Context, id string, attempt, done, total int) error
- func (r *Repo) Purge(_ context.Context, id string) error
- func (r *Repo) PurgeFinishedJobs(_ context.Context, before time.Time) (int, error)
- func (r *Repo) PurgeIdempotencyKeys(_ context.Context, before time.Time) (int, error)
- func (r *Repo) ReapJobs(_ context.Context, ttl time.Duration) (int, error)
- func (r *Repo) ReleaseIdempotencyKey(ctx context.Context, key string) error
- func (r *Repo) RequestCancel(ctx context.Context, id string) (*metadata.Job, error)
- func (r *Repo) StorageKeys(context.Context) (map[string]struct{}, error)
- func (r *Repo) UpdateMetadata(ctx context.Context, id string, tags map[string]any, merge bool) (*metadata.File, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repo ¶
type Repo struct {
// FailCreate makes every Create and CreateForKey fail, to exercise the
// orphan-cleanup paths above this seam.
FailCreate bool
// contains filtered or unexported fields
}
Repo is a concurrency-safe in-memory repository. Every method honours context cancellation the way pgx does, so a caller that must run after its request context is gone can be tested for it.
func (*Repo) ClaimIdempotencyKey ¶
func (*Repo) CreateForKey ¶
func (*Repo) HeartbeatJob ¶
func (*Repo) List ¶
List mirrors the pgx query: live rows unless IncludeDeleted, content-type equality, JSONB-style tag containment, the entries scope, and keyset paging by id descending — UUIDv7 ids sort by creation time, as in Postgres.