Documentation
¶
Overview ¶
Package schema provides the core data models and types for the tracking system.
Index ¶
- func AssertAllCoreColumnsPresent(columns []Column, coreColumns []Interface) error
- func AssertAllDependenciesFulfilled(columns []Column) error
- func AssertAllDependenciesFulfilledWithCoreColumns(columns []Column, coreColumns []Interface) error
- func FromColumns[T Column](columns []T) *arrow.Schema
- func SortByOrdering[T Column](cols []T, ordering OrderKeeper) []T
- func WithExtraFields[T Column](columns []T, extraFields ...arrow.Field) *arrow.Schema
- type Column
- type Columns
- type ColumnsRegistry
- type DependencySorter
- type DependsOnEntry
- type Documentation
- type Event
- type EventColumn
- type Guard
- type Interface
- type InterfaceID
- type InterfaceOrdering
- type Layout
- type LayoutRegistry
- type OrderKeeper
- type Session
- type SessionColumn
- type SessionScopedEventColumn
- type TableRows
- type Version
- type WithName
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertAllCoreColumnsPresent ¶
AssertAllCoreColumnsPresent validates that all core column interfaces have corresponding implementations.
func AssertAllDependenciesFulfilled ¶
AssertAllDependenciesFulfilled validates that all column dependencies are satisfied.
func AssertAllDependenciesFulfilledWithCoreColumns ¶
AssertAllDependenciesFulfilledWithCoreColumns validates that all column dependencies are satisfied and that all core columns are present.
func FromColumns ¶
FromColumns creates an Arrow schema from a slice of columns.
func SortByOrdering ¶ added in v0.10.0
func SortByOrdering[T Column](cols []T, ordering OrderKeeper) []T
SortByOrdering sorts a slice of columns according to their interface order.
Types ¶
type Column ¶
type Column interface {
Docs() Documentation
Implements() Interface
DependsOn() []DependsOnEntry
}
Column represents a column with metadata and dependencies.
func ToGenericColumns ¶
ToGenericColumns converts a slice of typed columns to a slice of generic Column interfaces.
type Columns ¶
type Columns struct {
Session []SessionColumn
Event []EventColumn
SessionScopedEvent []SessionScopedEventColumn
}
Columns groups the column sources for a table layout
func NewColumns ¶
func NewColumns(session []SessionColumn, event []EventColumn, sessionScoped []SessionScopedEventColumn) Columns
NewColumns creates a new Columns struct with session, event and session-scoped-event columns.
func Sorted ¶ added in v0.10.0
func Sorted(columns Columns, ordering OrderKeeper) Columns
Sorted sorts a slice of columns according to their interface order.
type ColumnsRegistry ¶
ColumnsRegistry is a registry of columns for different properties.
func NewColumnsMerger ¶
func NewColumnsMerger(registries []ColumnsRegistry) ColumnsRegistry
NewColumnsMerger creates a new columns merger.
func NewStaticColumnsRegistry ¶
func NewStaticColumnsRegistry(columns map[string]Columns, defaultColumns Columns) ColumnsRegistry
NewStaticColumnsRegistry creates a new static columns registry with the given columns.
type DependencySorter ¶
type DependencySorter struct{}
DependencySorter provides topological sorting functionality for columns with dependencies.
func NewDependencySorter ¶
func NewDependencySorter() *DependencySorter
NewDependencySorter creates a new dependency sorter.
func (*DependencySorter) SortAllColumns ¶
func (s *DependencySorter) SortAllColumns(columns Columns) (Columns, error)
SortAllColumns sorts both session and event columns together, respecting cross-type dependencies.
func (*DependencySorter) SortEventColumns ¶
func (s *DependencySorter) SortEventColumns(columns []EventColumn) ([]EventColumn, error)
SortEventColumns sorts event columns based on their dependencies.
func (*DependencySorter) SortSessionColumns ¶
func (s *DependencySorter) SortSessionColumns(columns []SessionColumn) ([]SessionColumn, error)
SortSessionColumns sorts session columns based on their dependencies.
type DependsOnEntry ¶
type DependsOnEntry struct {
Interface InterfaceID
GreaterOrEqualTo Version
LessThan Version
}
DependsOnEntry represents a dependency requirement for a column.
type Documentation ¶ added in v0.9.0
type Documentation struct {
ColumnName string
Type *arrow.Field
DisplayName string
InterfaceID string
Description string
}
Documentation represents the documentation for a column.
type Event ¶
Event represents a test event with bound hit and all hits.
type EventColumn ¶
EventColumn represents a column that can be written to during event processing.
type Guard ¶
type Guard struct {
// contains filtered or unexported fields
}
Guard ensures that warehouse tables have the correct schema and columns.
func NewGuard ¶
func NewGuard( warehouseRegistry warehouse.Registry, columnsColumns ColumnsRegistry, layout LayoutRegistry, ordering OrderKeeper, ) *Guard
NewGuard creates a new Guard
func (*Guard) EnsureTables ¶
EnsureTables creates tables and adds missing columns for the specified property.
type Interface ¶
type Interface struct {
ID InterfaceID
Version Version
Field *arrow.Field
}
Interface represents a virtual column, with given name, version and a field (including column name and type) Various parts of the system may then provide implementations of this interface. As example you can use something like "event_type". You may centrally define an abstract column interface, and then provide implementations in the protocols, which may have different understanding of what really means "event_type".
type InterfaceOrdering ¶ added in v0.10.0
type InterfaceOrdering struct {
// contains filtered or unexported fields
}
InterfaceOrdering maintains the order of column interfaces based on their definition position in structs.
func NewInterfaceDefinitionOrderKeeper ¶ added in v0.10.1
func NewInterfaceDefinitionOrderKeeper(structs ...any) *InterfaceOrdering
NewInterfaceDefinitionOrderKeeper creates a new OrderKeeper instance, that tracks the order of columns using the definition position in structs.
func (*InterfaceOrdering) GetOrder ¶ added in v0.10.0
func (o *InterfaceOrdering) GetOrder(id InterfaceID) int
GetOrder returns the order index for a given interface ID. Returns math.MaxInt for unknown interfaces (they sort last).
type Layout ¶
type Layout interface {
Tables(columns Columns) []WithName
ToRows(columns Columns, sessions ...*Session) ([]TableRows, error)
}
Layout is the interface for a table layout, implementations take control over the final schema and dictate the format of writing the session data to the table.
func NewEmbeddedSessionColumnsLayout ¶
NewEmbeddedSessionColumnsLayout creates a single table, with all the session columns embedded in the event table, with given prefix.
type LayoutRegistry ¶
LayoutRegistry is a registry of layouts for different properties.
func NewStaticLayoutRegistry ¶
func NewStaticLayoutRegistry(layouts map[string]Layout, defaultLayout Layout) LayoutRegistry
NewStaticLayoutRegistry creates a new static layout registry with the given layouts.
type OrderKeeper ¶ added in v0.10.1
type OrderKeeper interface {
GetOrder(id InterfaceID) int
}
OrderKeeper is a interface that can be used to get the order of a given interface ID.
func NewNoParticicularOrderKeeper ¶ added in v0.10.1
func NewNoParticicularOrderKeeper() OrderKeeper
NewNoParticicularOrderKeeper creates a new OrderKeeper that assigns an order to each interface ID in the order they are encountered, useful for testing or quick prototyping.
type Session ¶
type Session struct {
PropertyID string
Metadata map[string]any
Events []*Event
Values map[string]any
}
Session represents a session with events and values.
func NewSession ¶ added in v0.10.0
NewSession creates a new session from a slice of events.
type SessionColumn ¶
SessionColumn represents a column that can be written to during session processing.
type SessionScopedEventColumn ¶ added in v0.2.0
SessionScopedEventColumn represents a column computed with session scope that writes per-event values while having access to the whole session. It complements EventColumn and SessionColumn without changing their semantics.