Documentation
¶
Index ¶
- Constants
- Variables
- func CreateHighlightedItem(item list.Item, searchQuery string) list.Item
- func DebugLog(format string, args ...interface{})
- func DefaultExportPath(topic string, m api.Message) string
- func ExportMessageJSON(path string, topic string, m api.Message) error
- func FilterItems(items []list.Item, query string, caseSensitive bool) []list.Item
- func FormatBytes2dp(n int64) string
- func FormatConfigValue(name, value string, sensitive bool) string
- func FormatDiskUsage(segmentSize int64, segmentCount int) string
- func FormatISR(inSync, replica int) (text string, alert bool)
- func FormatSkew(skew *float64) string
- func FormatTimestamp(t time.Time) string
- func FuzzyFilterItems(items []list.Item, query string, caseSensitive bool) []list.Item
- func FuzzyMatch(query, text string, caseSensitive bool) bool
- func HighlightSearchMatches(text, searchQuery string) string
- func HighlightSearchMatchesWithConfig(text, searchQuery string, config HighlightConfig) string
- func InitLogger()
- func IsValidDimensions(width, height int) bool
- func NaturalLess(a, b string) bool
- func RemoveHighlighting(text string) string
- func SavePrefs(p Prefs) error
- func SetTimezone(name string) error
- func SkewSeverity(skew *float64) int
- func SortResourceListNaturally(items []list.Item)
- func SortResourceListWithOptions(items []list.Item, options SortOptions)
- func SortStringSlice(items []string, options SortOptions)
- func SortTableRowsNaturally(rows []table.Row)
- func SortTableRowsWithOptions(rows []table.Row, options SortOptions)
- func WriteBrokerCSV(w io.Writer, brokers []api.BrokerInfo, stats map[int32]api.BrokerStats) error
- func WriteConsumerGroupCSV(w io.Writer, groups []api.ConsumerGroup) error
- func WriteMessagesCSV(w io.Writer, msgs []api.Message, f CSVFormat) error
- func WriteTopicCSV(w io.Writer, topics []TopicCSVRow) error
- type CSVFormat
- type ConsumerGroupListItem
- type FilterableItem
- type HighlightConfig
- type HighlightableItem
- type HighlightedResourceListItem
- type HighlightedTopicItem
- type MessageListItem
- type MinimalResourceItem
- type NaturalSort
- type Navigation
- type PageState
- type Prefs
- type ResourceItem
- type ResourceListItem
- type SavedFilter
- type SearchConfig
- type SelectableItem
- type SlogWriter
- type SortOptions
- type SortOrder
- type StatusInfo
- type StatusType
- type TableConfig
- type TopicCSVRow
- type TopicListItem
- type TopicProjection
- type UIError
- type ViewDimensions
Constants ¶
const ( SkewNone = 0 // below the warning threshold (or absent) SkewWarning = 1 // |skew| >= 10% SkewError = 2 // |skew| >= 20% )
Skew severity levels returned by SkewSeverity, used to pick a display style.
const ( DefaultTableHeight = 20 DefaultSidebarWidth = 35 DefaultHeaderHeight = 3 MinContentWidth = 50 MinContentHeight = 10 )
Common constants
const ( ErrorTypeDataLoad = "data_load" ErrorTypeValidation = "validation" ErrorTypeRender = "render" ErrorTypeConfiguration = "configuration" ErrorTypeConnection = "connection" ErrorTypeAuthentication = "authentication" ErrorTypeTimeout = "timeout" )
Common error types
const ConfigValueMask = "**********"
ConfigValueMask is the placeholder shown in place of a sensitive config value.
Variables ¶
var BrokerCSVHeader = []string{
"ID", "Host", "Port", "Rack", "Disk Usage", "Leaders", "Replicas", "ISR", "Leader Skew", "Replica Skew",
}
BrokerCSVHeader is the column header row written by WriteBrokerCSV. It is shared so the in-app export and the `kafui get brokers --format csv` subcommand always agree on layout.
var ConsumerGroupCSVHeader = []string{
"Group ID", "Members", "Topics", "Lag", "Coordinator", "State",
}
ConsumerGroupCSVHeader is the column header row written by WriteConsumerGroupCSV.
var Log *slog.Logger = slog.Default() // safe default until Init is called
Log is the application-wide structured logger. Available after InitLogger(). Other packages should use this directly:
shared.Log.Info("message", "key", value)
shared.Log.Error("something failed", "err", err)
var MessageCSVHeader = []string{"Partition", "Offset", "Timestamp", "Key", "Value", "Headers"}
MessageCSVHeader is the column header row.
var TopicCSVHeader = []string{
"Name", "Partitions", "Replication Factor", "Message Count", "Out Of Sync", "Size", "Internal",
}
TopicCSVHeader is the column header row written by WriteTopicCSV.
Functions ¶
func CreateHighlightedItem ¶
CreateHighlightedItem creates a highlighted version of a list item
func DebugLog ¶
func DebugLog(format string, args ...interface{})
DebugLog is a backward-compatible shim for code that uses the old API.
func DefaultExportPath ¶
DefaultExportPath returns "./<topic>-<partition>-<offset>.json".
func ExportMessageJSON ¶
ExportMessageJSON writes the message to path as pretty JSON containing key, value, offset, partition, headers (as an object/map name->value), and timestamp (RFC3339). Creates parent dirs as needed.
func FilterItems ¶
FilterItems filters a slice of items based on a search query
func FormatBytes2dp ¶
FormatBytes2dp renders a byte count as a human-readable size with two decimal places using binary (1024) steps and SI-style unit labels (B, KB, MB, GB, …). Bytes below 1 KB are shown as a whole number, e.g. "512 B", larger values as "1.00 GB". Negative values are returned verbatim (as a signed byte count).
func FormatConfigValue ¶
FormatConfigValue renders a broker config value for display:
- sensitive entries are masked as ConfigValueMask;
- keys ending ".bytes" with a positive integer value are shown as a human-readable size (non-positive / non-numeric values pass through as-is);
- keys ending ".ms" get an " ms" suffix appended;
- everything else is returned unchanged.
func FormatDiskUsage ¶
FormatDiskUsage renders a broker's disk usage cell: "<size 2dp>, N segment(s)" or "N/A" when no log-dir data is available (segment count is zero).
func FormatISR ¶
FormatISR renders the in-sync-replica cell as "isr/replica". The cell is empty when the replica count is unavailable (<= 0). alert reports whether ISR is below the replica count (i.e. under-replicated) so the caller can style it.
func FormatSkew ¶
FormatSkew renders a skew percentage as "%.2f%%" or "-" when absent (nil).
func FormatTimestamp ¶
FormatTimestamp renders t in the configured display timezone.
func FuzzyFilterItems ¶
FuzzyFilterItems filters items using fuzzy matching
func FuzzyMatch ¶
FuzzyMatch performs fuzzy matching between a query and text
func HighlightSearchMatches ¶
HighlightSearchMatches highlights search query matches in text using lipgloss
func HighlightSearchMatchesWithConfig ¶
func HighlightSearchMatchesWithConfig(text, searchQuery string, config HighlightConfig) string
HighlightSearchMatchesWithConfig highlights search matches with custom configuration
func InitLogger ¶
func InitLogger()
InitLogger sets up the rotating file logger at ~/.kafui/kafui.log. It is idempotent and safe to call multiple times.
func IsValidDimensions ¶
IsValidDimensions checks if the provided dimensions are valid for UI rendering
func NaturalLess ¶
NaturalLess compares two strings naturally (numeric parts as numbers)
func RemoveHighlighting ¶
RemoveHighlighting removes highlighting from text
func SetTimezone ¶
SetTimezone configures the display timezone from a config value: "local" (or ""), "UTC", or any IANA name (e.g. "Europe/Berlin"). An unknown name falls back to local time and returns an error so the caller can warn.
func SkewSeverity ¶
SkewSeverity classifies a skew value for styling: SkewError when |skew| >= 20%, SkewWarning when |skew| >= 10%, otherwise SkewNone. Absent (nil) is SkewNone.
func SortResourceListNaturally ¶
SortResourceListNaturally sorts a slice of list items using natural sorting
func SortResourceListWithOptions ¶
func SortResourceListWithOptions(items []list.Item, options SortOptions)
SortResourceListWithOptions sorts a slice of list items with the given options
func SortStringSlice ¶
func SortStringSlice(items []string, options SortOptions)
SortStringSlice sorts a string slice with the given options
func SortTableRowsNaturally ¶
SortTableRowsNaturally sorts a slice of table rows using natural sorting
func SortTableRowsWithOptions ¶
func SortTableRowsWithOptions(rows []table.Row, options SortOptions)
SortTableRowsWithOptions sorts a slice of table rows with the given options
func WriteBrokerCSV ¶
func WriteBrokerCSV(w io.Writer, brokers []api.BrokerInfo, stats map[int32]api.BrokerStats) error
WriteBrokerCSV writes brokers as CSV to w, enriched with stats when available. The ID column is annotated "(Active)" for the controller. Disk usage and skew columns reuse the shared list-cell formatters so UI and CSV output match. Rows are ordered by broker ID for deterministic output.
func WriteConsumerGroupCSV ¶
func WriteConsumerGroupCSV(w io.Writer, groups []api.ConsumerGroup) error
WriteConsumerGroupCSV writes consumer groups as CSV to w. Undefined lag is written as an empty cell (never 0); unknown coordinator (<0) is empty too. Rows are ordered by group id for deterministic output.
func WriteMessagesCSV ¶
WriteMessagesCSV writes msgs as CSV to w using the given format. Header row first, then one row per message. Headers column joins each "name=value" header with commas (a single field). Timestamp is RFC3339 (empty if zero).
func WriteTopicCSV ¶
func WriteTopicCSV(w io.Writer, topics []TopicCSVRow) error
WriteTopicCSV writes topics as CSV to w. Rows are ordered by name for deterministic output. Unknown message counts/sizes (negative) render "N/A"; sizes are formatted human-readably via FormatBytes2dp.
Types ¶
type CSVFormat ¶
type CSVFormat struct {
Separator rune // field separator, default ','
Quote rune // quote char, default '"'
QuoteAll bool // quote every field when true
LineTerminator string // default "\n"
}
CSVFormat configures message CSV output.
func DefaultCSVFormat ¶
func DefaultCSVFormat() CSVFormat
DefaultCSVFormat returns the default RFC-4180-ish format (comma, double-quote, \n).
type ConsumerGroupListItem ¶
type ConsumerGroupListItem struct {
GroupID string
Group api.ConsumerGroup
Selected bool
Highlighted bool
SearchQuery string
}
ConsumerGroupListItem represents a consumer group item for list display
func (ConsumerGroupListItem) FilterValue ¶
func (c ConsumerGroupListItem) FilterValue() string
func (ConsumerGroupListItem) GetID ¶
func (c ConsumerGroupListItem) GetID() string
func (ConsumerGroupListItem) IsSelected ¶
func (c ConsumerGroupListItem) IsSelected() bool
func (*ConsumerGroupListItem) SetSelected ¶
func (c *ConsumerGroupListItem) SetSelected(selected bool)
type FilterableItem ¶
type FilterableItem interface {
FilterValue() string
}
FilterableItem represents an item that can be filtered
type HighlightConfig ¶
type HighlightConfig struct {
BackgroundColor string
ForegroundColor string
Bold bool
CaseSensitive bool
UseRegex bool
}
HighlightConfig contains options for text highlighting
func DefaultHighlightConfig ¶
func DefaultHighlightConfig() HighlightConfig
DefaultHighlightConfig returns default highlighting configuration
func SearchHighlightConfig ¶
func SearchHighlightConfig() HighlightConfig
SearchHighlightConfig returns highlighting configuration for search matches Only changes font color, no background highlighting
type HighlightableItem ¶
type HighlightableItem interface {
GetDisplayText() string
SetHighlight(query string)
ClearHighlight()
}
HighlightableItem represents an item that can have highlighted content
type HighlightedResourceListItem ¶
type HighlightedResourceListItem struct {
ResourceItem ResourceItem
SearchQuery string
}
HighlightedResourceListItem wraps a resource item with search highlighting info
func (HighlightedResourceListItem) FilterValue ¶
func (h HighlightedResourceListItem) FilterValue() string
func (HighlightedResourceListItem) GetID ¶
func (h HighlightedResourceListItem) GetID() string
type HighlightedTopicItem ¶
HighlightedTopicItem wraps a topic item with search highlighting info
func (HighlightedTopicItem) FilterValue ¶
func (h HighlightedTopicItem) FilterValue() string
func (HighlightedTopicItem) GetID ¶
func (h HighlightedTopicItem) GetID() string
type MessageListItem ¶
type MessageListItem struct {
Message api.Message
Index int
Selected bool
Highlighted bool
SearchQuery string
}
MessageListItem represents a message item for display
func (MessageListItem) FilterValue ¶
func (m MessageListItem) FilterValue() string
func (MessageListItem) GetID ¶
func (m MessageListItem) GetID() string
func (MessageListItem) IsSelected ¶
func (m MessageListItem) IsSelected() bool
func (*MessageListItem) SetSelected ¶
func (m *MessageListItem) SetSelected(selected bool)
type MinimalResourceItem ¶
type MinimalResourceItem struct {
ID string
}
MinimalResourceItem is a minimal implementation of ResourceItem for fallback cases
func (*MinimalResourceItem) GetDetails ¶
func (m *MinimalResourceItem) GetDetails() map[string]string
func (*MinimalResourceItem) GetID ¶
func (m *MinimalResourceItem) GetID() string
func (*MinimalResourceItem) GetValues ¶
func (m *MinimalResourceItem) GetValues() []string
type NaturalSort ¶
type NaturalSort []string
NaturalSort sorts strings in natural order (numbers in logical order)
func (NaturalSort) Len ¶
func (s NaturalSort) Len() int
func (NaturalSort) Less ¶
func (s NaturalSort) Less(i, j int) bool
func (NaturalSort) Swap ¶
func (s NaturalSort) Swap(i, j int)
type Prefs ¶
type Prefs struct {
HideInternalTopics bool `json:"hideInternalTopics"`
// SavedFilters are named smart-filter expressions (MSG-25).
SavedFilters []SavedFilter `json:"savedFilters,omitempty"`
// Projections maps a topic name to its column projections (MSG-26).
Projections map[string]TopicProjection `json:"projections,omitempty"`
}
Prefs holds small, user-local UI preferences persisted across runs. Add fields as new persisted toggles are introduced.
type ResourceItem ¶
ResourceItem represents a displayable resource item
type ResourceListItem ¶
type ResourceListItem struct {
ResourceItem ResourceItem
Selected bool
Highlighted bool
SearchQuery string
}
ResourceListItem wraps a resource item for list display
func (ResourceListItem) FilterValue ¶
func (r ResourceListItem) FilterValue() string
func (ResourceListItem) GetID ¶
func (r ResourceListItem) GetID() string
func (ResourceListItem) IsSelected ¶
func (r ResourceListItem) IsSelected() bool
func (*ResourceListItem) SetSelected ¶
func (r *ResourceListItem) SetSelected(selected bool)
type SavedFilter ¶
SavedFilter is a named smart-filter expression persisted across runs (MSG-25).
type SearchConfig ¶
SearchConfig represents search configuration
type SelectableItem ¶
SelectableItem represents an item that can be selected
type SlogWriter ¶
type SlogWriter struct {
// contains filtered or unexported fields
}
SlogWriter is an io.Writer that routes each written line into a *slog.Logger at INFO level. Use it to redirect legacy log.Logger or fmt.Fprintf calls (e.g. sarama.Logger, errWriter) into the structured log file without touching the terminal.
func NewSlogWriter ¶
func NewSlogWriter(logger *slog.Logger) *SlogWriter
NewSlogWriter creates a new SlogWriter backed by the given logger.
type SortOptions ¶
SortOptions contains options for sorting operations
func DefaultSortOptions ¶
func DefaultSortOptions() SortOptions
DefaultSortOptions returns default sorting options
type StatusInfo ¶
type StatusInfo struct {
Message string
Type StatusType
Timestamp string
Persistent bool
}
StatusInfo represents status information for display
type StatusType ¶
type StatusType int
StatusType represents different types of status messages
const ( StatusTypeInfo StatusType = iota StatusTypeSuccess StatusTypeWarning StatusTypeError )
type TableConfig ¶
type TableConfig struct {
Columns []table.Column
Styles table.Styles
Width int
Height int
ShowHeader bool
Selectable bool
}
TableConfig represents table configuration
type TopicCSVRow ¶
type TopicCSVRow struct {
Name string
Partitions int32
ReplicationFactor int16
MessageCount int64
OutOfSync int
Size int64
Internal bool
}
TopicCSVRow is one topic's exported row. MessageCount/Size are negative when unknown (rendered "N/A").
type TopicListItem ¶
type TopicListItem struct {
Name string
Topic api.Topic
Selected bool
Highlighted bool
SearchQuery string
}
TopicListItem represents a topic item for list display
func (TopicListItem) FilterValue ¶
func (t TopicListItem) FilterValue() string
func (TopicListItem) GetID ¶
func (t TopicListItem) GetID() string
func (TopicListItem) IsSelected ¶
func (t TopicListItem) IsSelected() bool
func (*TopicListItem) SetSelected ¶
func (t *TopicListItem) SetSelected(selected bool)
type TopicProjection ¶
TopicProjection holds the key/value JSON-path projections for a topic's message table columns (MSG-26). Empty path means "no projection".
type ViewDimensions ¶
type ViewDimensions struct {
Width int
Height int
ContentWidth int
ContentHeight int
SidebarWidth int
HeaderHeight int
}
ViewDimensions represents view dimensions and layout information
func CalculateContentDimensions ¶
func CalculateContentDimensions(totalWidth, totalHeight, sidebarWidth, footerHeight, headerHeight int) ViewDimensions
Helper functions for common operations
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package aclcsv provides pure CSV serialization/parsing of ACL bindings and a declarative sync (diff + apply) between a desired binding set and the cluster.
|
Package aclcsv provides pure CSV serialization/parsing of ACL bindings and a declarative sync (diff + apply) between a desired binding set and the cluster. |