Documentation
¶
Index ¶
- type Cache
- func (c *Cache) ApplySnapshot(snapshot Snapshot)
- func (c *Cache) CollectionsMeta() []collection.Meta
- func (c *Cache) ComponentID() events.ComponentID
- func (c *Cache) CreateBullet(collectionID string, bullet collectiondetail.Bullet) error
- func (c *Cache) CreateBulletWithMeta(collectionID string, bullet collectiondetail.Bullet, meta map[string]string) error
- func (c *Cache) CreateBulletWithMetaContext(ctx context.Context, collectionID string, bullet collectiondetail.Bullet, ...) error
- func (c *Cache) CreateCollection(meta collection.Meta) []*viewmodel.ParsedCollection
- func (c *Cache) DeleteBullet(collectionID, bulletID string)
- func (c *Cache) DeleteCollection(name string) []*viewmodel.ParsedCollection
- func (c *Cache) Events() <-chan tea.Msg
- func (c *Cache) RegisterSectionTemplate(section collectiondetail.Section)
- func (c *Cache) SectionSnapshot(id string) (collectiondetail.Section, bool)
- func (c *Cache) SetCollections(metas []collection.Meta)
- func (c *Cache) SetSections(sections []collectiondetail.Section)
- func (c *Cache) SetService(svc Service)
- func (c *Cache) Snapshot() Snapshot
- func (c *Cache) SyncCollection(ctx context.Context, collectionID string) error
- func (c *Cache) UpdateBullet(collectionID string, bullet collectiondetail.Bullet)
- func (c *Cache) UpdateCollection(current collection.Meta, previous *collection.Meta) []*viewmodel.ParsedCollection
- type Options
- type Service
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache maintains in-memory collections/entries and emits typed events on mutation. It mirrors the behavior of a Kubernetes-style informer cache: state lives locally, watchers subscribe to emitted events, and consumers read consistent snapshots without hitting the store.
func New ¶
func New(component events.ComponentID) *Cache
New creates an empty cache that will emit events using the provided ComponentID (falls back to "cache" if empty).
func NewWithOptions ¶
NewWithOptions constructs a cache using the supplied options.
func (*Cache) ApplySnapshot ¶
ApplySnapshot reconciles the cache with the provided snapshot, emitting collection/bullet change events for any detected differences.
func (*Cache) CollectionsMeta ¶
func (c *Cache) CollectionsMeta() []collection.Meta
CollectionsMeta returns a copy of the cached collection metadata list.
func (*Cache) ComponentID ¶
func (c *Cache) ComponentID() events.ComponentID
ComponentID returns the cache instance identifier used for emitted events.
func (*Cache) CreateBullet ¶
func (c *Cache) CreateBullet(collectionID string, bullet collectiondetail.Bullet) error
CreateBullet appends a bullet to the specified collection, emits a bullet change message, and returns the updated section.
func (*Cache) CreateBulletWithMeta ¶
func (c *Cache) CreateBulletWithMeta(collectionID string, bullet collectiondetail.Bullet, meta map[string]string) error
CreateBulletWithMeta mirrors CreateBullet but allows callers to specify additional metadata (e.g., parent assignment).
func (*Cache) CreateBulletWithMetaContext ¶
func (c *Cache) CreateBulletWithMetaContext(ctx context.Context, collectionID string, bullet collectiondetail.Bullet, meta map[string]string) error
CreateBulletWithMetaContext mirrors CreateBulletWithMeta but allows callers to supply the context used for persistence calls.
func (*Cache) CreateCollection ¶
func (c *Cache) CreateCollection(meta collection.Meta) []*viewmodel.ParsedCollection
CreateCollection inserts metadata and emits a CollectionChangeMsg. It returns the parsed tree for the new state.
func (*Cache) DeleteBullet ¶
DeleteBullet removes the specified bullet ID from the collection and emits a delete change message.
func (*Cache) DeleteCollection ¶
func (c *Cache) DeleteCollection(name string) []*viewmodel.ParsedCollection
DeleteCollection removes a collection (and children) and emits a delete change message.
func (*Cache) RegisterSectionTemplate ¶
func (c *Cache) RegisterSectionTemplate(section collectiondetail.Section)
RegisterSectionTemplate stores presentation metadata for a collection so future dynamically created sections inherit the correct title/subtitle.
func (*Cache) SectionSnapshot ¶
func (c *Cache) SectionSnapshot(id string) (collectiondetail.Section, bool)
SectionSnapshot returns a copy of the requested section.
func (*Cache) SetCollections ¶
func (c *Cache) SetCollections(metas []collection.Meta)
SetCollections seeds the cache with the provided metadata list. It rebuilds the parsed tree and emits no events (callers should emit ChangeMsgs if desired). Safe to call multiple times (it replaces state).
func (*Cache) SetSections ¶
func (c *Cache) SetSections(sections []collectiondetail.Section)
SetSections seeds the detail sections backing the collection detail pane.
func (*Cache) SetService ¶
SetService wires the cache to a persistence-backed Service for writes.
func (*Cache) Snapshot ¶
Snapshot returns a copy of the current parsed collections and sections. The returned data should be treated as immutable by callers.
func (*Cache) SyncCollection ¶
SyncCollection refreshes a single collection detail section from the configured service, emitting bullet diff events.
func (*Cache) UpdateBullet ¶
func (c *Cache) UpdateBullet(collectionID string, bullet collectiondetail.Bullet)
UpdateBullet replaces an existing bullet (matched by ID) and emits an update.
func (*Cache) UpdateCollection ¶
func (c *Cache) UpdateCollection(current collection.Meta, previous *collection.Meta) []*viewmodel.ParsedCollection
UpdateCollection applies metadata changes and emits an Update change message.
type Options ¶
type Options struct {
Component events.ComponentID
Service Service
Clock clock.Clock
}
Options configure cache construction.
type Service ¶
type Service interface {
CollectionsMeta(ctx context.Context, prefix string) ([]collection.Meta, error)
Entries(ctx context.Context, collectionID string) ([]*entry.Entry, error)
Add(ctx context.Context, collection string, bullet glyph.Bullet, msg string, sig glyph.Signifier) (*entry.Entry, error)
SetParent(ctx context.Context, id, parentID string) (*entry.Entry, error)
}
Service describes the journal data access needed by the cache.
type Snapshot ¶
type Snapshot struct {
Metas []collection.Meta
Collections []*viewmodel.ParsedCollection
Sections []collectiondetail.Section
}
Snapshot exposes the current cached state.
func BuildSnapshot ¶
BuildSnapshot loads collection metadata and entry sections from the supplied service, assembling a cache snapshot that mirrors on-disk state.