mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-11 22:14:02 +01:00
common/schema: turns into a component
This is a first step to make it accept configuration. Most of the changes are quite trivial, but I also ran into some difficulties with query columns and filters. They need the schema for parsing, but parsing happens before dependencies are instantiated (and even if it was not the case, parsing is stateless). Therefore, I have added a `Validate()` method that must be called after instantiation. Various bits `panic()` if not validated to ensure we catch all cases. The alternative to make the component manages a global state would have been simpler but it would break once we add the ability to add or disable columns.
This commit is contained in:
19
common/schema/root.go
Normal file
19
common/schema/root.go
Normal file
@@ -0,0 +1,19 @@
|
||||
// SPDX-FileCopyrightText: 2023 Free Mobile
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
// Package schema is an abstraction of the data schema for flows used by
|
||||
// Akvorado. It is a leaky abstraction as there are multiple parts dependant of
|
||||
// the subsystem that will use it.
|
||||
package schema
|
||||
|
||||
// Component represents the schema compomenent.
|
||||
type Component struct {
|
||||
Schema
|
||||
}
|
||||
|
||||
// New creates a new schema component.
|
||||
func New() (*Component, error) {
|
||||
return &Component{
|
||||
Schema: flows(),
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user