storage

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package storage persists JobForge state as plain JSON files. We use JSON (not SQLite) because the data is small, hand-editable, easy to inspect, and keeps the project stdlib-only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store is the on-disk repository for jobs, profile, and drafts. A single mutex covers all writes; concurrency is not a hot path for a CLI but the guarantee keeps tests honest.

func New

func New(p config.Paths) *Store

New constructs a Store at the given paths. It does not touch disk.

func (*Store) ActiveResume

func (s *Store) ActiveResume() (resume.Resume, bool, error)

ActiveResume returns the resume marked active, or false if none is set.

func (*Store) AddSource

func (s *Store) AddSource(src source.Source) (source.Source, error)

AddSource validates and stores a new source.

func (*Store) FindJob

func (s *Store) FindJob(idOrPrefix string) (job.Job, error)

FindJob looks up a job by exact ID or an unambiguous ID prefix.

func (*Store) FindResume

func (s *Store) FindResume(idOrPrefix string) (resume.Resume, error)

FindResume looks up a resume by exact ID or an unambiguous ID prefix.

func (*Store) FindSource

func (s *Store) FindSource(idOrPrefix string) (source.Source, error)

FindSource looks up a source by exact ID or an unambiguous ID prefix.

func (*Store) ImportResume

func (s *Store) ImportResume(srcPath string) (resume.Resume, error)

ImportResume copies srcPath into the resumes directory and records its metadata. If no resume is currently active, the new one becomes active so the writer agent has something to use immediately.

func (*Store) Init

func (s *Store) Init() error

Init creates the data directory and seeds empty files when missing. It is safe to call multiple times.

func (*Store) LoadAppConfig

func (s *Store) LoadAppConfig() (config.AppConfig, error)

LoadAppConfig returns the persisted app config or the default if absent.

func (*Store) LoadJobs

func (s *Store) LoadJobs() ([]job.Job, error)

LoadJobs returns all tracked jobs sorted by CreatedAt (newest first).

func (*Store) LoadProfile

func (s *Store) LoadProfile() (profile.Profile, error)

LoadProfile returns the saved profile or a fresh skeleton if absent.

func (*Store) LoadResumes

func (s *Store) LoadResumes() ([]resume.Resume, error)

LoadResumes returns all imported resumes sorted by ImportedAt (newest first).

func (*Store) LoadSources

func (s *Store) LoadSources() ([]source.Source, error)

LoadSources returns all configured public job sources sorted newest first.

func (*Store) MarkSourceChecked

func (s *Store) MarkSourceChecked(id string, checkedAt time.Time) error

MarkSourceChecked records a successful check timestamp.

func (*Store) Paths

func (s *Store) Paths() config.Paths

Paths exposes the resolved paths for callers that need to print them.

func (*Store) RemoveResume

func (s *Store) RemoveResume(idOrPrefix string) (resume.Resume, error)

RemoveResume deletes a resume's file and removes it from the registry. If the removed resume was active, no other resume is auto-promoted - the user must explicitly set-active to avoid surprising writer behavior.

func (*Store) RemoveSource

func (s *Store) RemoveSource(idOrPrefix string) (source.Source, error)

RemoveSource removes a configured source from the registry.

func (*Store) SaveAppConfig

func (s *Store) SaveAppConfig(c config.AppConfig) error

SaveAppConfig writes the app config atomically.

func (*Store) SaveDraft

func (s *Store) SaveDraft(jobID, body string) (string, error)

SaveDraft persists a generated draft to drafts/<jobID>.txt and returns the absolute path of the written file.

func (*Store) SaveJobs

func (s *Store) SaveJobs(jobs []job.Job) error

SaveJobs writes the full job list atomically.

func (*Store) SaveProfile

func (s *Store) SaveProfile(p profile.Profile) error

SaveProfile writes the profile atomically.

func (*Store) SaveResumes

func (s *Store) SaveResumes(rs []resume.Resume) error

SaveResumes writes the resume registry atomically.

func (*Store) SaveSources

func (s *Store) SaveSources(sources []source.Source) error

SaveSources writes the full source list atomically.

func (*Store) SetActiveResume

func (s *Store) SetActiveResume(idOrPrefix string) (resume.Resume, error)

SetActiveResume marks one resume active and clears the flag on all others.

func (*Store) UpsertJob

func (s *Store) UpsertJob(j job.Job) ([]job.Job, error)

UpsertJob inserts or replaces a job by ID and returns the updated list.

Jump to

Keyboard shortcuts

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