Documentation
¶
Index ¶
- type Capture
- type CaptureCursor
- type CaptureFilter
- type CaptureHistory
- func (h *CaptureHistory) All() []connections.ConnectionList
- func (h *CaptureHistory) At(cursor CaptureCursor) (connections.ConnectionList, bool)
- func (h *CaptureHistory) Latest() (CaptureCursor, bool)
- func (h *CaptureHistory) Len() int
- func (h *CaptureHistory) MustLatest() CaptureCursor
- func (h *CaptureHistory) Oldest() (CaptureCursor, bool)
- func (h *CaptureHistory) Position(cursor CaptureCursor) (n, total int)
- func (h *CaptureHistory) Push(list connections.ConnectionList) CaptureCursor
- func (h *CaptureHistory) Step(cursor CaptureCursor, delta int) (CaptureCursor, bool)
- type CaptureReader
- type CaptureStart
- type CaptureTarget
- type CaptureWriter
- type ReplaySource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Capture ¶
type Capture struct {
At time.Time `json:"at"`
List connections.ConnectionList `json:"capture"`
}
func NewCapture ¶
func NewCapture(list connections.ConnectionList) Capture
type CaptureCursor ¶
type CaptureCursor int
CaptureCursor identifies a capture stored in a CaptureHistory. Cursors are monotonic and stable across eviction — once a cursor's capture is evicted, At returns false for it, but subsequent captures keep advancing the cursor space so the model can hold a step position without recomputing on push.
type CaptureFilter ¶
type CaptureFilter struct {
Instance string `json:"instance,omitempty"`
Role string `json:"role,omitempty"`
}
CaptureFilter records any client-side row filter active at capture time so replay tooling can tell a partial snapshot from a complete branch view. Omitted when no filter was set.
type CaptureHistory ¶
type CaptureHistory struct {
// contains filtered or unexported fields
}
CaptureHistory is a capped ring of captured ConnectionLists. New captures push out the oldest once capacity is reached.
func NewCaptureHistory ¶
func NewCaptureHistory(capacity int) *CaptureHistory
func (*CaptureHistory) All ¶
func (h *CaptureHistory) All() []connections.ConnectionList
func (*CaptureHistory) At ¶
func (h *CaptureHistory) At(cursor CaptureCursor) (connections.ConnectionList, bool)
func (*CaptureHistory) Latest ¶
func (h *CaptureHistory) Latest() (CaptureCursor, bool)
func (*CaptureHistory) Len ¶
func (h *CaptureHistory) Len() int
func (*CaptureHistory) MustLatest ¶
func (h *CaptureHistory) MustLatest() CaptureCursor
MustLatest panics when history is empty — convenient in tests where a caller has just pushed and knows the history is non-empty.
func (*CaptureHistory) Oldest ¶
func (h *CaptureHistory) Oldest() (CaptureCursor, bool)
func (*CaptureHistory) Position ¶
func (h *CaptureHistory) Position(cursor CaptureCursor) (n, total int)
Position returns the 1-based index of cursor in the live window and the total number of retained samples. Returns (0, total) when cursor has been evicted.
func (*CaptureHistory) Push ¶
func (h *CaptureHistory) Push(list connections.ConnectionList) CaptureCursor
Push stores list and returns its cursor. The Connections slice is cloned so callers can mutate (e.g. sort in place) without corrupting history.
func (*CaptureHistory) Step ¶
func (h *CaptureHistory) Step(cursor CaptureCursor, delta int) (CaptureCursor, bool)
Step moves cursor by delta, clamped to [Oldest, Latest]. Returns the new cursor and whether it moved. A cursor outside the live range is treated as "off the oldest edge" / "off the newest edge" — positive delta from below snaps to the oldest, negative from above snaps to the latest.
type CaptureReader ¶
type CaptureReader struct {
// contains filtered or unexported fields
}
CaptureReader reads Capture records from a stream previously written by CaptureWriter. It skips capture_start headers and rejects unsupported schema versions on capture_start.
func NewCaptureReader ¶
func NewCaptureReader(r io.Reader) *CaptureReader
func (*CaptureReader) CaptureStart ¶
func (r *CaptureReader) CaptureStart() (CaptureStart, bool)
CaptureStart returns the parsed capture_start metadata when the trace contains a well-formed header.
func (*CaptureReader) Read ¶
func (r *CaptureReader) Read() (Capture, error)
Read returns the next Capture in the stream, or io.EOF when exhausted. A torn final line (no trailing newline, partial JSON) is treated as EOF so captures interrupted by SIGINT remain replayable.
func (*CaptureReader) ReadAll ¶
func (r *CaptureReader) ReadAll() ([]Capture, error)
ReadAll consumes the stream and returns every complete capture in order.
type CaptureStart ¶
type CaptureStart struct {
Type string `json:"type"`
At time.Time `json:"at"`
Organization string `json:"org"`
Database string `json:"database"`
Branch string `json:"branch"`
SchemaVersion int `json:"schema_version"`
Filter *CaptureFilter `json:"filter,omitempty"`
Target *CaptureTarget `json:"target,omitempty"`
}
type CaptureTarget ¶
type CaptureTarget struct {
Keyspace string `json:"keyspace,omitempty"`
Shard string `json:"shard,omitempty"`
}
CaptureTarget records the Vitess target active at capture time.
type CaptureWriter ¶
type CaptureWriter struct {
// contains filtered or unexported fields
}
CaptureWriter writes captures as newline-delimited JSON records.
func NewCaptureWriter ¶
func NewCaptureWriter(writer io.Writer) *CaptureWriter
func (*CaptureWriter) Close ¶
func (w *CaptureWriter) Close() error
func (*CaptureWriter) Flush ¶
func (w *CaptureWriter) Flush() error
func (*CaptureWriter) Write ¶
func (w *CaptureWriter) Write(capture Capture) error
func (*CaptureWriter) WriteCaptureStart ¶
func (w *CaptureWriter) WriteCaptureStart(start CaptureStart) error
type ReplaySource ¶
type ReplaySource struct {
// contains filtered or unexported fields
}
ReplaySource serves captured snapshots from a trace file as if they were live.
func NewReplaySource ¶
func NewReplaySource(r io.Reader) (*ReplaySource, error)
NewReplaySource loads every Capture from r into memory. Returns an error when the trace contains no complete capture records — replay against an empty or header-only file is not meaningful.
func (*ReplaySource) CaptureStart ¶
func (s *ReplaySource) CaptureStart() (CaptureStart, bool)
CaptureStart returns the trace metadata header when the capture file has one.
func (*ReplaySource) Captures ¶
func (s *ReplaySource) Captures() []Capture
Captures returns the loaded captures in order. Used by the CLI to seed the TUI's capture history so the operator can step the full timeline.
func (*ReplaySource) List ¶
func (s *ReplaySource) List(_ context.Context, mode connections.SortMode) (connections.ConnectionList, error)
List returns the latest captured snapshot, sorted by mode.