store

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package store persists canonical OmniDevX events as daily JSONL files:

<dir>/events/YYYY/MM/DD/<product>.jsonl

Plain text keeps the store inspectable — a developer can read exactly what has been recorded about them — and reprocessable when metric formulas change. Writes are idempotent: an event whose deterministic ID already exists in its day file is skipped, so re-importing overlapping history does not duplicate.

The default root is ~/.plexusone/omnidevx/data. Files are created with owner-only permissions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Dir is the store root. Defaults to ~/.plexusone/omnidevx/data.
	Dir string
}

Options configures a Store.

type Query

type Query struct {
	// Period filters by event timestamp (half-open, zero bounds open).
	Period omnidevx.Period
	// Product, when set, reads only that source product's files.
	Product string
}

Query scopes a Read. A zero Query reads everything.

type ReadResult

type ReadResult struct {
	Events      []omnidevx.Event
	Diagnostics []omnidevx.Diagnostic
}

ReadResult carries events plus diagnostics for damaged lines.

type Store

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

Store reads and writes canonical events under a root directory.

func Open

func Open(opts Options) (*Store, error)

Open returns a Store rooted at opts.Dir, creating the directory if needed.

func (*Store) Dir

func (s *Store) Dir() string

Dir returns the store root.

func (*Store) Read

func (s *Store) Read(ctx context.Context, q Query) (*ReadResult, error)

Read returns stored events matching the query, ordered by timestamp. Damaged lines become diagnostics, never silent drops.

func (*Store) Write

func (s *Store) Write(ctx context.Context, events []omnidevx.Event) (*WriteResult, error)

Write persists events, grouping them into day files by timestamp and product. Events whose ID already exists in their day file are counted as duplicates and skipped. Events without an ID, type, or timestamp are rejected.

type WriteResult

type WriteResult struct {
	Written    int `json:"written"`
	Duplicates int `json:"duplicates"`
}

WriteResult reports the outcome of a Write.

Jump to

Keyboard shortcuts

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