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 ¶
- Variables
- func ValidID(id string) bool
- type Store
- func (s *Store) Create(ctx context.Context, r *domain.Run) (string, error)
- func (s *Store) CreateTx(tx *storage.Tx, r *domain.Run) error
- func (s *Store) Get(ctx context.Context, id string) (*domain.Run, error)
- func (s *Store) List(ctx context.Context) ([]*domain.Run, error)
- func (s *Store) ReadSnapshot(ctx context.Context, id string) (*domain.Run, []byte, error)
- func (s *Store) Update(ctx context.Context, r *domain.Run, expected []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("run not found") ErrBadID = errors.New("invalid run id") )
Errors reported to callers.
Functions ¶
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store binds Run operations to a project root.
func New ¶
New binds the run layer to a project root (the directory containing .devsys, which must exist).
func (*Store) Create ¶
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 ¶
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) List ¶
List decodes every run, ordered by (date, numeric suffix) — stable and independent of directory enumeration.
func (*Store) ReadSnapshot ¶
ReadSnapshot returns a run with the raw bytes it was decoded from, for read-modify-write cycles that pass the bytes back into Update.