adapter

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package adapter bridges the production backend (TrackerService, ResourcePatchStore) to the new TUI's Store interface. It provides LiveStore (thread-safe, in-memory) and TUIRevisionHandler (collector -> TUI message bridge).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LiveRevisionMsg

type LiveRevisionMsg struct {
	ResourceUID string
}

LiveRevisionMsg tells the TUI that a new revision has been ingested into the LiveStore. The TUI should refresh its views: data is already in the store.

type LiveStore

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

LiveStore implements tui.Store backed by in-memory maps. Thread-safe: the collector goroutine writes (IngestRevision), the TUI goroutine reads.

func NewLiveStore

func NewLiveStore() *LiveStore

NewLiveStore creates an empty LiveStore.

func (*LiveStore) AddRevision

func (s *LiveStore) AddRevision(resourceUID string, rev resource.Revision)

func (*LiveStore) AddWatchKind

func (s *LiveStore) AddWatchKind(rk resource.Kind) []*resource.Data

func (*LiveStore) AllResources

func (s *LiveStore) AllResources() []*resource.Data

func (*LiveStore) FilterResources

func (s *LiveStore) FilterResources(expr string) []*resource.Data

func (*LiveStore) FilterTimeline

func (s *LiveStore) FilterTimeline(expr string, starredOnly bool) []resource.TimelineEntry

func (*LiveStore) ForEachResource

func (s *LiveStore) ForEachResource(fn func(uid string, rd *resource.Data))

func (*LiveStore) GetResource

func (s *LiveStore) GetResource(uid string) *resource.Data

func (*LiveStore) IngestRevision

func (s *LiveStore) IngestRevision(
	uid, kind, name, namespace string,
	rev resource.Revision,
)

IngestRevision adds a revision for a resource. If the resource doesn't exist yet, it is created. This is thread-safe and designed for high-throughput ingestion.

func (*LiveStore) KindGroups

func (s *LiveStore) KindGroups() []*resource.KindGroup

func (*LiveStore) RebuildKindGroups

func (s *LiveStore) RebuildKindGroups()

func (*LiveStore) RemoveWatchKind

func (s *LiveStore) RemoveWatchKind(kind string)

func (*LiveStore) ResourceCountByKind

func (s *LiveStore) ResourceCountByKind(kind string) int

func (*LiveStore) RevisionCountByKind

func (s *LiveStore) RevisionCountByKind(kind string) int

func (*LiveStore) SetUnwatchedKinds

func (s *LiveStore) SetUnwatchedKinds(kinds []resource.Kind)

SetUnwatchedKinds sets the list of unwatched resource kinds available on the cluster.

func (*LiveStore) SortTimeline

func (s *LiveStore) SortTimeline()

SortTimeline orders the timeline newest-first by revision time. IngestRevision keeps the timeline in arrival order, which is correct for live events but not for a bulk history load that walks one resource's revisions at a time. Call this once after loading history so the timeline is globally chronological.

func (*LiveStore) StarredResources

func (s *LiveStore) StarredResources() []*resource.Data

func (*LiveStore) Timeline

func (s *LiveStore) Timeline() []resource.TimelineEntry

func (*LiveStore) ToggleStar

func (s *LiveStore) ToggleStar(uid string) bool

func (*LiveStore) TotalResourceCount

func (s *LiveStore) TotalResourceCount() int

func (*LiveStore) TotalRevisionCount

func (s *LiveStore) TotalRevisionCount() int

func (*LiveStore) UnwatchedKinds

func (s *LiveStore) UnwatchedKinds() []resource.Kind

func (*LiveStore) WatchedKinds

func (s *LiveStore) WatchedKinds() []string

type TUIRevisionHandler

type TUIRevisionHandler struct {
	Store   *LiveStore
	Program *tea.Program
}

TUIRevisionHandler implements the revisionHandler interface from cmd/root.go. It ingests each revision into the LiveStore and sends a LiveRevisionMsg to the bubbletea program so the UI refreshes.

func (*TUIRevisionHandler) HandleRevision

func (h *TUIRevisionHandler) HandleRevision(
	obj *unstructured.Unstructured,
	revisionID store.RevisionID,
	snapshot *store.Snapshot,
	patch *store.Patch,
) error

HandleRevision is called by the collector goroutine (and loadHistoryFromDB) for each new or historic revision. It extracts resource metadata from the unstructured object, builds a resource.Revision, ingests it into the LiveStore, and notifies the TUI.

The obj parameter always contains the full object state at this revision:

  • In the collector path: obj is the live watch event object
  • In the history path: obj is reconstructed from snapshot + patches

Jump to

Keyboard shortcuts

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