store

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package store holds an imported workspace in memory. Data becomes visible one complete chunk at a time, and every change bumps a revision so readers can describe a consistent view while an import is still running.

Index

Constants

View Source
const (
	OriginLogs     = "logs"
	OriginBundle   = "bundle"
	OriginReviewer = "reviewer"
)

Origins of a flow row.

View Source
const (
	PhaseWaiting   = "waiting"
	PhaseLoading   = "loading"
	PhaseComplete  = "complete"
	PhaseFailed    = "failed"
	PhaseCancelled = "cancelled"
)

Import phases.

View Source
const (
	StateComplete     = "complete"
	StateLoading      = "loading"
	StateExcluded     = "excluded"
	StateFailed       = "failed"
	StateTruncated    = "truncated"
	StateNotCollected = "not-collected"
	// StateRemoved: the customer took the whole type out in review.
	StateRemoved = "removed"
	// StateTrimmed: the customer removed some objects of the type in review;
	// the rest are here, but absence proves nothing.
	StateTrimmed = "trimmed"
)

Collection states shown to users.

View Source
const PhaseLive = "live"

PhaseLive is a workspace that mirrors a running cluster: the initial list has completed and watches keep it up to date.

View Source
const SourceLive = "live"

SourceLive marks a header written by flightbay-desk live.

View Source
const SuggestLimit = 50

SuggestLimit caps how many suggestions a call returns.

View Source
const SynthesisedAnnotation = "flightbay.dev/synthesised"

SynthesisedAnnotation marks objects the workspace built rather than captured.

Variables

View Source
var AgwRequestFields = []string{
	"gateway", "listener", "route", "endpoint", "src.addr", "src.identity", "jwt.sub",
	"http.method", "http.host", "http.status", "protocol", "reason",
	"mcp.method.name", "mcp.method", "mcp.target", "mcp.resource.type", "gen_ai.tool.name", "mcp.tool.name", "mcp.tool", "gen_ai.prompt.name",
	"a2a.method", "gen_ai.operation.name", "gen_ai.provider.name", "llm.provider", "gen_ai.request.model", "gen_ai.response.model",
}

AgwRequestFields are the request log fields AgentgatewayRequests groups on. Names come from agentgateway's request logger (crates/agentgateway/src/telemetry/log.rs); older builds used mcp.method and mcp.tool, and llm.provider before gen_ai.provider.name.

View Source
var ErrNotReadOnly = errors.New("only read-only queries are allowed: SELECT, WITH, FROM, DESCRIBE, SHOW, SUMMARIZE, EXPLAIN")

ErrNotReadOnly rejects statements that could change the workspace.

Functions

This section is empty.

Types

type AccessEdge

type AccessEdge struct {
	Cluster      string   `json:"cluster"`
	SrcNamespace string   `json:"srcNamespace"`
	SrcPod       string   `json:"srcPod"`
	SrcIdentity  string   `json:"srcIdentity"`
	DstService   string   `json:"dstService"` // host, e.g. name.ns.svc.cluster.local, or an external host
	DstNamespace string   `json:"dstNamespace"`
	DstWorkload  string   `json:"dstWorkload"`
	Methods      []string `json:"methods"`
	Paths        []string `json:"paths"` // up to five examples
	Requests     int      `json:"requests"`
	Denied       int      `json:"denied"` // 401/403 responses or policy rejections

	DstIdentity string `json:"dstIdentity,omitempty"`
	// HBONE counts connections carried over HBONE (mutual TLS between
	// ztunnels, port 15008); Plaintext counts the rest. Both are per side, the
	// larger taken, like Requests.
	HBONE     int       `json:"hbone"`
	Plaintext int       `json:"plaintext"`
	BytesSent int64     `json:"bytesSent,omitempty"` // by the source
	BytesRecv int64     `json:"bytesRecv,omitempty"`
	First     time.Time `json:"first"`
	Last      time.Time `json:"last"`
	// Connections counts connection lines (scope access) and HTTPRequests
	// request lines (scope http_access in some ztunnel builds); Requests is both.
	Connections  int `json:"connections"`
	HTTPRequests int `json:"httpRequests"`
}

AccessEdge is traffic seen in mesh access logs between a source pod and a destination Service, aggregated over the capture.

type AgwRequest

type AgwRequest struct {
	Cluster   string            `json:"cluster"`
	Namespace string            `json:"namespace"` // of the gateway pod that logged it
	Pod       string            `json:"pod"`
	Fields    map[string]string `json:"fields"`
	Count     int               `json:"count"`

	InputTokens  int64   `json:"inputTokens,omitempty"`
	OutputTokens int64   `json:"outputTokens,omitempty"`
	CacheRead    int64   `json:"cacheRead,omitempty"`
	CacheWrite   int64   `json:"cacheWrite,omitempty"`
	Cost         float64 `json:"cost,omitempty"`

	First time.Time `json:"first"`
	Last  time.Time `json:"last"`
	// Error is one example of the error field, when the group has one.
	Error string `json:"error,omitempty"`
}

AgwRequest is a group of agentgateway request log lines that agree on every field the activity map keeps. Token counts and cost are summed over the group rather than grouped on.

type Bucket

type Bucket struct {
	Start time.Time `json:"start"`
	Count int       `json:"count"`
}

Bucket is one histogram bar.

type Collection

type Collection struct {
	State  string `json:"state"`
	Reason string `json:"reason,omitempty"`
	Items  int    `json:"items"`
}

Collection is the state of one resource collection.

type Diagnostic

type Diagnostic struct {
	Cluster   string            `json:"cluster"`
	Kind      string            `json:"kind"` // proxies or control-plane
	Namespace string            `json:"namespace"`
	Pod       string            `json:"pod"`
	Component string            `json:"component"`
	Container string            `json:"container"`
	Image     string            `json:"image"`
	Version   string            `json:"version"`
	Node      string            `json:"node"`
	Files     map[string][]byte `json:"-"`
}

Diagnostic is one component's captured admin output.

type ErrorMinute

type ErrorMinute struct {
	Cluster, Namespace string
	Minute             time.Time
	Count              int
}

ErrorMinute counts error lines in one namespace in one minute.

type Event

type Event struct {
	Cluster string         `json:"cluster"`
	Obj     map[string]any `json:"object"`
	RV      int64          `json:"-"` // revision the event was stored at; watches use it to spot updates
}

Event is a captured Kubernetes event.

type FieldCounter

type FieldCounter struct {
	Value string `json:"value"`
	Count int    `json:"count"`
}

FieldCounter is one value and how many matching lines carry it.

type FieldValues

type FieldValues struct {
	Field  string         `json:"field"`
	Count  int            `json:"count"`
	Values []FieldCounter `json:"values"`
}

FieldValues is one parsed field with its most common values.

type Flow

type Flow = flows.Flow

Flow is one observed connection or request, normalised from any source: ztunnel, agentgateway, Envoy (waypoints and sidecars), CoreDNS query logs, or flow logs imported alongside the bundle (Cilium Hubble, Calico, AWS, GCP and Azure VPC flow logs, or a generic CSV/JSON). Endpoints are named when the source names them and otherwise carried as IPs; internal/reach resolves IPs to workloads from the captured pod, Service and node addresses.

The type lives in internal/flows, where the parsers are; this alias keeps store.Flow as the name the rest of Flightbay codes against.

type FlowFileResult

type FlowFileResult struct {
	File   string `json:"file"`
	Format string `json:"format"`
	Flows  int    `json:"flows"`   // aggregated rows
	Events int    `json:"records"` // records they stand for
}

FlowFileResult is what ImportFlowFile loaded.

type ImportState

type ImportState struct {
	Phase         string     `json:"phase"`
	Source        string     `json:"source"`
	BytesReceived int64      `json:"bytesReceived"`
	Members       int        `json:"members"`
	Objects       int        `json:"objects"`
	LogLines      int        `json:"logLines"`
	LogsSkipped   int        `json:"logsSkipped,omitempty"` // lines not indexed because of the memory budget
	Events        int        `json:"events"`
	CoverageSeen  int        `json:"coverageSeen"`
	Verified      bool       `json:"verified"`
	Error         string     `json:"error,omitempty"`
	Started       time.Time  `json:"started"`
	Finished      time.Time  `json:"finished,omitempty"`
	Revision      int64      `json:"revision"`
	Deferred      []string   `json:"deferred,omitempty"`
	Live          *LiveState `json:"live,omitempty"` // set by flightbay-desk live
}

ImportState is the progress of the running import.

type LineLoc

type LineLoc struct {
	ID    int64  `json:"id"`
	Chunk string `json:"chunk"`
	Index int    `json:"index"`
	Raw   string `json:"raw"`
}

LineLoc places a log line in the bundle: its chunk member and its position among the chunk's non-empty lines, which is how a review plan names it.

type LiveState

type LiveState struct {
	Live            bool             `json:"live"`
	Context         string           `json:"context"`
	Server          string           `json:"server"`
	Connected       bool             `json:"connected"`
	LastEvent       time.Time        `json:"lastEvent"`
	Reconnects      int64            `json:"reconnects"`
	Watches         int              `json:"watches"`
	ObjectsWatched  int              `json:"objectsWatched"`
	LogStreams      int              `json:"logStreams"`
	LogStreamsTotal int              `json:"logStreamsTotal"`
	LogLinesDropped int64            `json:"logLinesDropped"`
	MaxLogStreams   int              `json:"maxLogStreams"`
	MaxLogLines     int              `json:"maxLogLines"`
	Diagnostics     bool             `json:"diagnostics"`
	Requests        map[string]int64 `json:"requests,omitempty"` // requests made to the cluster, by verb
	Refused         int64            `json:"refused"`            // requests the read-only guard refused
}

LiveState describes the connection behind a live workspace.

type LogFilter

type LogFilter struct {
	Query     string
	Cluster   string
	Namespace string
	Pod       string
	Container string
	Level     string
	Stream    string
	Workload  string // Kind/name or name
	From, To  time.Time
	Limit     int
	Offset    int
}

LogFilter selects log records.

type LogResult

type LogResult struct {
	Total     int                       `json:"total"`
	Records   []*logs.Record            `json:"records"`
	Facets    map[string]map[string]int `json:"facets"`
	Histogram []Bucket                  `json:"histogram"`
	Revision  int64                     `json:"revision"`
	Scanned   int                       `json:"scanned"`
	Loading   bool                      `json:"loading"`
	Message   string                    `json:"message,omitempty"`
	From      time.Time                 `json:"from"`
	To        time.Time                 `json:"to"`
}

LogResult is a consistent page of search results.

type LogStreamKey

type LogStreamKey struct {
	Cluster, Namespace, Pod, Container, Stream string
}

LogStreamKey names one container log stream.

type Object

type Object struct {
	Cluster    string         `json:"cluster"`
	Group      string         `json:"group"`
	Version    string         `json:"version"`
	Resource   string         `json:"resource"`
	Kind       string         `json:"kind"`
	Namespaced bool           `json:"namespaced"`
	Namespace  string         `json:"namespace"`
	Name       string         `json:"name"`
	RV         int64          `json:"rv"`
	Obj        map[string]any `json:"object"`
}

Object is one captured Kubernetes object.

func (*Object) Labels

func (o *Object) Labels() map[string]string

Labels returns metadata.labels as strings.

type ObjectHit

type ObjectHit struct {
	Cluster   string            `json:"cluster"`
	Group     string            `json:"group"`
	Version   string            `json:"version"`
	Resource  string            `json:"resource"`
	Kind      string            `json:"kind"`
	Namespace string            `json:"namespace"`
	Name      string            `json:"name"`
	Labels    map[string]string `json:"labels,omitempty"`
	Match     string            `json:"match"`             // name, label or content
	Snippet   string            `json:"snippet,omitempty"` // where the free text matched
}

ObjectHit is one object found by SearchObjects.

type ObjectResult

type ObjectResult struct {
	Total   int            `json:"total"`
	ByKind  map[string]int `json:"byKind"`
	Results []ObjectHit    `json:"results"`
	Loading bool           `json:"loading"`
	Message string         `json:"message,omitempty"`
}

ObjectResult is a page of object search results.

type SQLResult

type SQLResult struct {
	Columns   []string `json:"columns"`
	Rows      [][]any  `json:"rows"`
	Truncated bool     `json:"truncated"`
	Millis    int64    `json:"ms"`
}

SQLResult is the result of a read-only query.

type Suggestion

type Suggestion struct {
	Value   string `json:"value"`
	Count   int    `json:"count"`
	Hint    string `json:"hint,omitempty"`
	Example string `json:"example,omitempty"`
	// More means the value is a stem, e.g. a label key, and the UI should
	// keep suggesting after inserting it rather than finish the term.
	More bool `json:"more,omitempty"`
}

Suggestion is one typeahead entry: a field key (when no field is given) or a value for a field, with how many captured objects or lines carry it.

func LogFieldKeys

func LogFieldKeys() []Suggestion

LogFieldKeys are the fixed keys the log query understands. Structured fields parsed from JSON or key=value lines come on top, see SuggestLogs.

func ObjectFieldKeys

func ObjectFieldKeys() []Suggestion

ObjectFieldKeys are the keys the object search understands.

type TimeBucket

type TimeBucket struct {
	Start       time.Time `json:"start"`
	Connections int       `json:"connections"` // ztunnel connections from the workload
	Requests    int       `json:"requests"`    // agentgateway requests it made
	ToolCalls   int       `json:"toolCalls"`
	LLMCalls    int       `json:"llmCalls"`
	Refused     int       `json:"refused"` // refused by ztunnel or agentgateway policy
	Errors      int       `json:"errors"`
	Tokens      int64     `json:"tokens"`
}

TimeBucket is one slice of the window.

type TimeEvent

type TimeEvent struct {
	At    time.Time `json:"at"`
	Kind  string    `json:"kind"` // connection, tool, model, refusal
	What  string    `json:"what"`
	Count int       `json:"count"`
}

TimeEvent is the first time something was seen in the window.

type Timeline

type Timeline struct {
	From    time.Time    `json:"from"`
	To      time.Time    `json:"to"`
	Step    int64        `json:"stepSeconds"`
	Buckets []TimeBucket `json:"buckets"`
	Events  []TimeEvent  `json:"events"`
}

Timeline is a workload's activity over the log window.

type TimelineFilter

type TimelineFilter struct {
	Cluster        string
	Pods           []string
	IdentitySuffix string // "/ns/kagent/sa/tom-demo"
	IPs            []string
	Buckets        int // default 60
}

TimelineFilter picks one workload's traffic out of the logs: its ztunnel access lines by pod name, and the agentgateway requests it made by mesh identity (a SPIFFE ID ending in /ns/<ns>/sa/<sa>) or pod address.

type Trust

type Trust struct {
	Signature *sign.Result    `json:"signature,omitempty"`
	Ledger    json.RawMessage `json:"ledger,omitempty"`
}

Trust is what the desk knows about where a bundle came from: its signature, checked once the whole bundle has been read, and the ledger of what the customer removed in review.

type Workspace

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

Workspace is one opened bundle.

func New

func New() *Workspace

New returns an empty workspace with an in-memory database (tests, diffs).

func Open

func Open(path string) (*Workspace, error)

Open returns an empty workspace whose logs, objects and events are stored in the DuckDB file at path (replaced if it exists). "" keeps it in memory.

func (*Workspace) AccessEdges

func (w *Workspace) AccessEdges(cluster string) []AccessEdge

AccessEdges aggregates ztunnel (and waypoint) access log lines. ztunnel writes one JSON line per connection (scope "access") or per HTTP request (scope "http_access" in some builds) with src.* and dst.* fields.

func (*Workspace) AddCRD

func (w *Workspace) AddCRD(cluster string, crd map[string]any)

AddCRD records a collected CustomResourceDefinition (schema stripped).

func (*Workspace) AddCollectionLog

func (w *Workspace) AddCollectionLog(lines []json.RawMessage)

AddCollectionLog appends collection-log.jsonl lines.

func (*Workspace) AddDiagnostic

func (w *Workspace) AddDiagnostic(cluster, kind, ns, pod, file string, data []byte)

AddDiagnostic records a diagnostic file (or meta.json) for a component pod.

func (*Workspace) AddEvents

func (w *Workspace) AddEvents(cluster string, items []map[string]any)

AddEvents commits one events chunk.

func (*Workspace) AddFlows

func (w *Workspace) AddFlows(fs []Flow) error

AddFlows appends flows to the flows table.

func (*Workspace) AddLogLines

func (w *Workspace) AddLogLines(cluster, ns, pod, container, stream string, lines []string, chunk string)

AddLogLines parses and commits one log chunk before returning.

func (*Workspace) AddObjects

func (w *Workspace) AddObjects(cluster string, r bundle.APIResource, items []map[string]any, chunk string)

AddObjects commits one resource chunk.

func (*Workspace) AddReviewerFlows

func (w *Workspace) AddReviewerFlows(cluster, name string, r io.Reader, format string) (FlowFileResult, error)

AddReviewerFlows imports a flow file chosen by the reviewer when opening the bundle and lists it on the Coverage page, marked as not part of the signed bundle.

func (*Workspace) AgentTimeline

func (w *Workspace) AgentTimeline(f TimelineFilter) Timeline

AgentTimeline returns one workload's connections, calls and refusals over the log window, and the first time each destination, tool, model and refusal was seen.

func (*Workspace) AgentgatewayRequests

func (w *Workspace) AgentgatewayRequests(cluster string) []AgwRequest

AgentgatewayRequests groups the agentgateway request logs (scope "request", text or JSON) of a cluster ("" for all). Ephemeral source ports are dropped so a caller's connections fall into one group.

func (*Workspace) AllLogStreams

func (w *Workspace) AllLogStreams() []LogStreamKey

AllLogStreams lists every stream with lines loaded.

func (*Workspace) AllObjects

func (w *Workspace) AllObjects(cluster string) []*Object

AllObjects returns every object in a cluster ("" for all clusters).

func (*Workspace) CRD

func (w *Workspace) CRD(cluster, group, resource string) map[string]any

CRD returns the definition for resource.group, or nil.

func (*Workspace) CRDs

func (w *Workspace) CRDs(cluster string) []map[string]any

CRDs returns the collected CRD definitions for a cluster, sorted by name.

func (*Workspace) Close

func (w *Workspace) Close() error

Close waits for queued log chunks and closes the database.

func (*Workspace) Clusters

func (w *Workspace) Clusters() []string

Clusters returns cluster names in bundle order.

func (*Workspace) CollectionLog

func (w *Workspace) CollectionLog() []json.RawMessage

CollectionLog returns the collection log.

func (*Workspace) CollectionState

func (w *Workspace) CollectionState(cluster, group, resource, kind string, namespaced bool) Collection

CollectionState tells loading, excluded, failed, truncated and complete apart.

func (*Workspace) Coverage

func (w *Workspace) Coverage() []bundle.Coverage

Coverage returns all coverage records.

func (*Workspace) CoverageRecord

func (w *Workspace) CoverageRecord(id string) (bundle.Coverage, bool)

CoverageRecord returns one coverage record by id.

func (*Workspace) DBPath

func (w *Workspace) DBPath() string

DBPath is the DuckDB file behind the workspace ("" when in memory).

func (*Workspace) DeleteEvent

func (w *Workspace) DeleteEvent(cluster, ns, name string) bool

DeleteEvent removes an event, reporting whether it was present.

func (*Workspace) DeleteObject

func (w *Workspace) DeleteObject(cluster, group, resource, ns, name string) bool

DeleteObject removes one object, as a watch DELETED event does, and reports whether it was present.

func (*Workspace) Diagnostic

func (w *Workspace) Diagnostic(cluster, kind, ns, pod string) *Diagnostic

Diagnostic returns one component pod's capture, or nil.

func (*Workspace) DiagnosticSummary

func (w *Workspace) DiagnosticSummary(cluster string) json.RawMessage

DiagnosticSummary returns the diagnostic component summary for a cluster.

func (*Workspace) Diagnostics

func (w *Workspace) Diagnostics(cluster string) []Diagnostic

Diagnostics lists captured components, optionally for one cluster.

func (*Workspace) ErrorMinutes

func (w *Workspace) ErrorMinutes(cluster string, min int) []ErrorMinute

ErrorMinutes returns minutes with at least min error lines per namespace.

func (*Workspace) Events

func (w *Workspace) Events(cluster string) []Event

Events returns captured events for a cluster ("" for all).

func (*Workspace) FindLogs

func (w *Workspace) FindLogs(query string, limit int) ([]*logs.Record, error)

FindLogs returns lines matching a query in load order, at most limit.

func (*Workspace) FindResource

func (w *Workspace) FindResource(cluster, name string) (bundle.APIResource, bool)

FindResource resolves "pods", "po", "deployments.apps" or a kind for a cluster.

func (*Workspace) Flows

func (w *Workspace) Flows(cluster string) []Flow

Flows returns every observed flow for a cluster ("" for all), from logs in the capture and any flow logs imported with it.

func (*Workspace) FlowsFrom

func (w *Workspace) FlowsFrom(cluster, source string) []Flow

FlowsFrom returns flows for one source ("" for all).

func (*Workspace) Get

func (w *Workspace) Get(cluster, group, resource, ns, name string) *Object

Get returns one object or nil.

func (*Workspace) HasChunk

func (w *Workspace) HasChunk(name string) bool

HasChunk reports whether a bundle member was already committed.

func (*Workspace) HasStream

func (w *Workspace) HasStream(cluster, ns, pod, container, stream string) bool

HasStream reports whether any line of a stream was loaded.

func (*Workspace) Header

func (w *Workspace) Header() *bundle.Header

Header returns bundle.json, nil before it arrives.

func (*Workspace) ImportFlowFile

func (w *Workspace) ImportFlowFile(cluster, name string, r io.Reader, format, origin string) (FlowFileResult, error)

ImportFlowFile parses a flow log file (format "" to detect it) and adds its flows under cluster, marked with the file name and origin (OriginBundle for a file inside the signed bundle, OriginReviewer for one added at open).

func (*Workspace) IsLive

func (w *Workspace) IsLive() bool

IsLive reports whether the workspace mirrors a running cluster, as opposed to a bundle (including a bundle saved from a live workspace).

func (*Workspace) LineLocation

func (w *Workspace) LineLocation(id int64) (*LineLoc, error)

LineLocation returns one line by id.

func (*Workspace) LineLocations

func (w *Workspace) LineLocations(f LogFilter, max int) ([]LineLoc, int, error)

LineLocations returns where the lines matching a log filter live, at most max of them, and how many match in total.

func (*Workspace) List

func (w *Workspace) List(cluster, group, resource, ns string, labels map[string]string) []*Object

List returns objects of one type, optionally in one namespace and matching labels.

func (*Workspace) LogContext

func (w *Workspace) LogContext(id int64, n int) []*logs.Record

LogContext returns up to n lines either side of a line in its stream.

func (*Workspace) LogFields

func (w *Workspace) LogFields(query, cluster string, maxFields, maxValues int) ([]FieldValues, error)

LogFields lists the parsed fields present in lines matching the query, most common first, each with its top values.

func (*Workspace) LogStream

func (w *Workspace) LogStream(cluster, ns, pod, container, stream string) []*logs.Record

LogStream returns a captured container stream in line order.

func (*Workspace) LogStreamFrom

func (w *Workspace) LogStreamFrom(cluster, ns, pod, container, stream string, from int) []*logs.Record

LogStreamFrom returns a stream's lines from sequence number from onwards.

func (*Workspace) LogStreamLines

func (w *Workspace) LogStreamLines() map[LogStreamKey]int

LogStreamLines returns every stream with lines loaded and how many, for workspaces (a live mirror) whose coverage does not list streams one by one.

func (*Workspace) Manifest

func (w *Workspace) Manifest() *bundle.Manifest

Manifest returns manifest.json, nil until the end of the stream.

func (*Workspace) MarkChunk

func (w *Workspace) MarkChunk(name string)

MarkChunk records that a bundle member has been committed, so a retried or repeated import does not add it twice.

func (*Workspace) Policy

func (w *Workspace) Policy() *policy.Policy

Policy returns the customer's collection policy.

func (*Workspace) PutCoverage

func (w *Workspace) PutCoverage(c bundle.Coverage)

PutCoverage records or replaces a coverage record without counting it as a newly received member (live workspaces rewrite their records).

func (*Workspace) QueueLogLines

func (w *Workspace) QueueLogLines(cluster, ns, pod, container, stream string, lines []string, chunk string, done func())

QueueLogLines reserves ids for a chunk in order and commits it in the background; searches see it once committed. Call WaitLogs before treating the import as complete.

func (*Workspace) Redaction

func (w *Workspace) Redaction() json.RawMessage

Redaction returns the redaction report.

func (*Workspace) RegisterResources

func (w *Workspace) RegisterResources(cluster string, rs []bundle.APIResource)

RegisterResources records discovery for a cluster.

func (*Workspace) RegisteredResources

func (w *Workspace) RegisteredResources(cluster string) []bundle.APIResource

RegisteredResources returns the resource types recorded by discovery or by objects, without the virtual types the workspace synthesises.

func (*Workspace) RemoveDiagnostic

func (w *Workspace) RemoveDiagnostic(cluster, kind, ns, pod string)

RemoveDiagnostic drops a component pod's captured diagnostics so a fresh capture replaces them rather than mixing with them.

func (*Workspace) Resources

func (w *Workspace) Resources(cluster string) []bundle.APIResource

Resources returns the resource types known for a cluster.

func (*Workspace) Revision

func (w *Workspace) Revision() int64

Revision is the current import revision.

func (*Workspace) SQL

func (w *Workspace) SQL(query string, limit int) (*SQLResult, error)

SQL runs one read-only statement against the workspace database: tables log_lines, objects, events and flows, and the view logs. It runs inside a transaction that is always rolled back, and the database has no access to the local file system.

func (*Workspace) SearchLogs

func (w *Workspace) SearchLogs(f LogFilter) (*LogResult, error)

SearchLogs evaluates a query over every committed line. The matches go into a temporary table once; facets, the histogram, the count and the page are all computed from it, so the text search runs once per request.

func (*Workspace) SearchObjects

func (w *Workspace) SearchObjects(query, cluster string, limit int) (*ObjectResult, error)

SearchObjects finds captured objects of any type. Terms:

kind:pod (also po, pods, deployment.apps, httproute)   ns:payments   cluster:mesh1
name:checkout*   label:app=checkout   label:app   "free text" (name, labels, spec, status...)
-term negates. Space is AND.

func (*Workspace) SetCoverage

func (w *Workspace) SetCoverage(c bundle.Coverage)

SetCoverage records a coverage record.

func (*Workspace) SetDiagnosticSummary

func (w *Workspace) SetDiagnosticSummary(cluster string, raw json.RawMessage)

SetDiagnosticSummary records the summary of detected diagnostic components.

func (*Workspace) SetHeader

func (w *Workspace) SetHeader(h *bundle.Header)

SetHeader records bundle.json and the resolved collection policy.

func (*Workspace) SetLedger

func (w *Workspace) SetLedger(raw json.RawMessage)

SetLedger records review-ledger.json.

func (*Workspace) SetManifest

func (w *Workspace) SetManifest(m *bundle.Manifest)

SetManifest records manifest.json.

func (*Workspace) SetRedaction

func (w *Workspace) SetRedaction(raw json.RawMessage)

SetRedaction records the redaction report.

func (*Workspace) SetSignature

func (w *Workspace) SetSignature(r sign.Result)

SetSignature records the result of checking manifest.sig.

func (*Workspace) SetState

func (w *Workspace) SetState(fn func(*ImportState))

SetState updates import progress.

func (*Workspace) SetVersion

func (w *Workspace) SetVersion(cluster string, raw json.RawMessage)

SetVersion records a cluster's /version.

func (*Workspace) State

func (w *Workspace) State() ImportState

State returns import progress.

func (*Workspace) Streams

func (w *Workspace) Streams(cluster, ns, pod string) []string

Streams lists the captured streams for a pod as container/stream.

func (*Workspace) Subscribe

func (w *Workspace) Subscribe() (<-chan struct{}, func())

Subscribe returns a channel signalled after every commit.

func (*Workspace) SuggestLogs

func (w *Workspace) SuggestLogs(field, prefix, query, cluster string, limit int) ([]Suggestion, error)

SuggestLogs lists values for one log query field that start with prefix, with line counts, narrowed by the field terms of query. An empty field returns the fixed keys and the most common structured fields.

func (*Workspace) SuggestObjects

func (w *Workspace) SuggestObjects(field, prefix, query, cluster string, limit int) ([]Suggestion, error)

SuggestObjects lists values for one object search field that start with prefix, narrowed by the structured terms (kind, ns, label...) of query. An empty field returns the keys. Values come from the captured objects.

func (*Workspace) TrimLogs

func (w *Workspace) TrimLogs(max int) int

TrimLogs deletes the oldest log lines so at most max remain, and returns how many were dropped. Live workspaces call it to keep the database bounded.

func (*Workspace) Trust

func (w *Workspace) Trust() Trust

Trust returns the signature and ledger recorded so far.

func (*Workspace) UpsertEvent

func (w *Workspace) UpsertEvent(cluster string, obj map[string]any)

UpsertEvent adds an event or replaces the one with the same name (a repeated event is the same object with a higher count).

func (*Workspace) UpsertObject

func (w *Workspace) UpsertObject(cluster string, r bundle.APIResource, obj map[string]any) bool

UpsertObject adds or replaces one object, as a watch ADDED or MODIFIED event does. The object gets a new resource version, the revision moves on and the SQL copy is replaced. It reports whether the object is new.

func (*Workspace) Version

func (w *Workspace) Version(cluster string) json.RawMessage

Version returns a cluster's /version response.

func (*Workspace) WaitLogs

func (w *Workspace) WaitLogs()

WaitLogs blocks until every queued log chunk is committed.

Directories

Path Synopsis
Package duckdb links DuckDB into the workspace store.
Package duckdb links DuckDB into the workspace store.
Package sqldriver is the hook between the workspace store and DuckDB.
Package sqldriver is the hook between the workspace store and DuckDB.

Jump to

Keyboard shortcuts

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