Refactor decoding of the Kea config
The package for decoding the Kea config should be refactored. It doesn't encapsulate the Kea configuration details enough and doesn't provide a complete toolkit to interpret the JSON data.
Many Kea configuration details leak to other parts of the applications. It causes the description of the Kea config structure to be duplicated across the Stork. For example, the primary function for decoding subnets is located in the dbmodel
package, outside the keaconfig
package. Additionally, the configreview
package defines a few partial decoders.
We duplicate these data to decode only the necessary data in a given context to decrease the performance impact. But the current solution breaks the encapsulation of Kea details (which is a wrong development practice). It causes the same data may be deserialized multiple times (it decreases the performance instead of increasing it).
We need to refactor the solution and wrap the Kea JSON with a struct to lazy access the decoded data. The struct will be responsible for deserializing data, encapsulating any Kea detail, and caching already decoded data.
Technical suggestion: We can try to investigate the possibility of using the RawMessage
from the encoding/json
package for lazy decoding of a JSON described by struct tags.