Documentation
¶
Overview ¶
Package events appends and filters the project event stream under .devsys/events/<YYYY-MM>.jsonl (方案 §4.6, 实施计划 M1.3). One event is one JSONL line; the shard follows the event time in UTC, and comment events carry a one-level reply_to.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotInitialized = storage.ErrNotInitialized ErrIncompleteTail = storage.ErrIncompleteTail ErrReplyNotFound = errors.New("reply_to does not reference a comment of the same subject") ErrReplyNotOneLevel = errors.New("reply_to must reference a top-level comment") ErrBadTime = errors.New("event time must be a valid UTC time") )
Errors reported to callers.
Functions ¶
func AppendBatchTx ¶
AppendBatchTx stages several events into one transaction. The transaction contract stages each JSONL file once, so events sharing a month shard are concatenated into a single append; events of different shards keep their own append. This keeps a completion (status change plus propagation events) atomic.
func AppendTx ¶
AppendTx stages one event into an existing storage transaction. supplies its own tx (already holding the project lock). ev.ID is assigned from ev.Time if empty; ev.Time is set to UTC now if zero. ev.SchemaVersion is set to domain.SchemaVersion if zero. Use this instead of reaching into tx.AppendJSONL directly: it centralises shard-path derivation and ID generation so callers don't reinvent the rules.
Types ¶
type CommentThread ¶
CommentThread is one top-level comment with its one-level replies, ordered by time.
type Filter ¶
type Filter struct {
// From and FromExclusive bound Time: inclusive and exclusive lower edge.
From time.Time
FromExclusive time.Time
// To bounds Time inclusively.
To time.Time
// Subject keeps events whose subject matches both fields.
Subject *domain.Reference
// Type keeps only events of this type.
Type string
}
Filter describes which events a reader wants. Zero fields match anything.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store binds event operations to a project root.
func New ¶
New binds the event stream to a project root (the directory containing .devsys, which must exist).
func (*Store) Append ¶
Append validates and writes one event. The shard follows the event's own time, so a December event written on January 1st still lands in the December file. The write is a JSONL append inside a storage transaction, so interrupted runs are recovered before the append is retried.
func (*Store) Comments ¶
Comments aggregates the comment events of a subject into threads. A reply must reference a comment of the same subject; deeper nesting (a reply to a reply) is rejected, so the thread tree is always two levels deep.