run

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package run persists Run records under .devsys/runs/<id>.yaml (方案 §14.3, 实施计划 M1.4). IDs are run-<YYYYMMDD>-<seq>; the sequence is re-derived from the directory inside the create transaction, and the create itself is a CAS, so concurrent creates never share an ID.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("run not found")
	ErrBadID    = errors.New("invalid run id")
)

Errors reported to callers.

Functions

func ValidID

func ValidID(id string) bool

ValidID reports whether id is a well-formed run identifier.

Types

type Store

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

Store binds Run operations to a project root.

func New

func New(root string) *Store

New binds the run layer to a project root (the directory containing .devsys, which must exist).

func (*Store) Create

func (s *Store) Create(ctx context.Context, r *domain.Run) (string, error)

Create persists a new run, assigning the next sequence number for today's date when the ID is empty. The write is guarded with ExpectAbsent, so two concurrent creates of the same number have exactly one winner; the loser rescan and retries.

func (*Store) CreateTx

func (s *Store) CreateTx(tx *storage.Tx, r *domain.Run) error

CreateTx stages a new run inside an existing storage transaction. The caller holds the project lock (via storage.Write) so the date-sequence scan and ExpectAbsent put both succeed or both fail with the caller's tx; concurrent claims never see a half-written run record. r.ID must be empty so the helper can derive it; the assigned ID is written back into r.

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (*domain.Run, error)

Get decodes one run.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]*domain.Run, error)

List decodes every run, ordered by (date, numeric suffix) — stable and independent of directory enumeration.

func (*Store) ReadSnapshot

func (s *Store) ReadSnapshot(ctx context.Context, id string) (*domain.Run, []byte, error)

ReadSnapshot returns a run with the raw bytes it was decoded from, for read-modify-write cycles that pass the bytes back into Update.

func (*Store) Update

func (s *Store) Update(ctx context.Context, r *domain.Run, expected []byte) error

Update replaces a run only while the file still matches expected, the raw bytes from the caller's read snapshot; a concurrent edit surfaces as storage.ErrConflict (乐观并发, 方案 §15.2).

Jump to

Keyboard shortcuts

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