memory

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package memory is an in-process jobsync storage driver.

It is not for production: jobs do not survive a restart, and every operation takes a process-wide lock. It exists as the control for the conformance suite. When a real driver fails a test, the memory driver answers the question "is the test wrong, or is the driver wrong?" — if the simplest possible implementation cannot satisfy it, the test is the thing to fix.

It is also genuinely useful in application tests, where a real queue is usually more infrastructure than the test needed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Storage

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

func New

func New() *Storage

New returns an empty in-process storage.

func (*Storage) AdvanceSchedule

func (s *Storage) AdvanceSchedule(ctx context.Context, id string, lastRun, nextRun time.Time) error

func (*Storage) Close

func (s *Storage) Close() error

func (*Storage) Counts

func (s *Storage) Counts(ctx context.Context) (jobsync.Counts, error)

func (*Storage) Delete

func (s *Storage) Delete(ctx context.Context, ids []string) error

func (*Storage) DueSchedules

func (s *Storage) DueSchedules(ctx context.Context, now time.Time) ([]jobsync.Schedule, error)

func (*Storage) Enqueue

func (s *Storage) Enqueue(ctx context.Context, jobs []*jobsync.Job) error

func (*Storage) Extend

func (s *Storage) Extend(ctx context.Context, ids []string, owner string, lease time.Duration) error

func (*Storage) Fetch

func (s *Storage) Fetch(ctx context.Context, queues []string, n int, owner string, lease time.Duration) ([]*jobsync.Job, error)

func (*Storage) Finish

func (s *Storage) Finish(ctx context.Context, id, owner string, r jobsync.Result) error

func (*Storage) Heartbeat

func (s *Storage) Heartbeat(ctx context.Context, info jobsync.ServerInfo, ttl time.Duration) error

func (*Storage) JobHistory

func (s *Storage) JobHistory(ctx context.Context, id string) (*jobsync.Job, []jobsync.Transition, error)

func (*Storage) ListJobs

func (s *Storage) ListJobs(ctx context.Context, f jobsync.Filter) ([]*jobsync.Job, int64, error)

func (*Storage) ListSchedules

func (s *Storage) ListSchedules(ctx context.Context) ([]jobsync.Schedule, error)

func (*Storage) Lock

func (s *Storage) Lock(ctx context.Context, key string, ttl time.Duration) (string, error)

Lock implements jobsync.Locker.

func (*Storage) PauseQueue

func (s *Storage) PauseQueue(ctx context.Context, name string) error

PauseQueue implements jobsync.QueueControl.

func (*Storage) PausedQueues

func (s *Storage) PausedQueues(ctx context.Context) ([]string, error)

func (*Storage) QueueStats

func (s *Storage) QueueStats(ctx context.Context) ([]jobsync.QueueStat, error)

func (*Storage) Reclaim

func (s *Storage) Reclaim(ctx context.Context) (int, error)

func (*Storage) RemoveSchedule

func (s *Storage) RemoveSchedule(ctx context.Context, id string) error

func (*Storage) Requeue

func (s *Storage) Requeue(ctx context.Context, ids []string) error

func (*Storage) ResumeQueue

func (s *Storage) ResumeQueue(ctx context.Context, name string) error

func (*Storage) SaveSchedule

func (s *Storage) SaveSchedule(ctx context.Context, sc jobsync.Schedule) error

SaveSchedule implements jobsync.Schedules. It is an upsert: every deploy re-registers its schedules, and appending would fire a job once per deploy that had ever happened.

func (*Storage) Servers

func (s *Storage) Servers(ctx context.Context) ([]jobsync.ServerInfo, error)

Servers reports nothing: an in-process storage has exactly one server and it is the one reading this. Returning an empty list is the contract's answer for a driver that keeps no registry.

func (*Storage) SetSchedulePaused

func (s *Storage) SetSchedulePaused(ctx context.Context, id string, paused bool) error

SetSchedulePaused implements jobsync.Schedules.

func (*Storage) Throughput

func (s *Storage) Throughput(ctx context.Context, since time.Time, bucket time.Duration) ([]jobsync.Bucket, error)

func (*Storage) Unlock

func (s *Storage) Unlock(ctx context.Context, key, token string) error

Unlock implements jobsync.Locker. The token check is what stops a server whose lock already expired from releasing the lock a different server now holds.

Jump to

Keyboard shortcuts

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