json

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package json provides a JSON-file-backed implementation of the pullrequest.PRTrackingRepository port.

The interface is satisfied by a single StateRepository that reads and writes one versioned JSON file, allowing atomic persistence of all cross-restart state in a single os.Rename call.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StateRepository

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

StateRepository implements pullrequest.PRTrackingRepository from a JSON file.

Reads are done by loading the full file on every call (the file is tiny). Writes are atomic: the new content is written to a ".tmp" sibling first, then renamed into place with os.Rename, which is atomic on Linux and macOS.

If the file is absent or corrupt the repository treats the state as empty and logs a warning — it never returns an error on load.

File permissions: 0600.

func NewStateRepository

func NewStateRepository(filePath string) *StateRepository

NewStateRepository creates a StateRepository backed by the file at filePath. The file need not exist; it will be created on the first write.

func (*StateRepository) Clear

func (r *StateRepository) Clear() error

─── Clear ───────────────────────────────────────────────────────────────────

func (*StateRepository) Fetch

func (*StateRepository) IsEmpty

func (r *StateRepository) IsEmpty() bool

func (*StateRepository) LoadAll

func (r *StateRepository) LoadAll() ([]*pullrequest.PullRequest, error)

LoadAll returns all previously saved PR snapshots. Returns an empty (non-nil) slice when no state has been persisted yet.

func (*StateRepository) Save

func (r *StateRepository) Save(pullrequests []*pullrequest.PullRequest) error

Save replaces the entire tracked-PR snapshot set and persists the change.

func (*StateRepository) Update

func (r *StateRepository) Update(pullRequest *pullrequest.PullRequest) error

Jump to

Keyboard shortcuts

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