Hi,
As promised on the call, here is the link to the playground with SPI for config
This package contains the “full” features similar to what we do in Helidon
- ParsableConfigSource and ConfigParser - parsers support a specific content type and can convert a stream to tree)
- NodeConfigSource - tree node supported by source
- PollableConfigSource and PollingStrategy - config source is mutable and can be polled for changes
- WatchableConfigSource and ChangeWatcher - config source is mutable and changes can be found via an event from change watcher
- EventConfigSource - config source is mutable and it can trigger mutation events on its own
- ConfigNode - the tree node (can be Object, List or Value - similar to Object. Array and Value in JSON)
There are a few classes in “example” package that implement some of these interfaces.
This is a work in progress - I am trying to extract meaningful API from Helidon Config, so we can compare with MP and maybe decide to update some areas.
The main advantages I see compared to current MP:
- well defined mutability approach (using snapshots + capability to get latest version based on change events); the only loose end are “lazy” config sources, as these may provide a value whenever they choose to do so
- tree structure from config source up - most config sources know the data in advance (files on class path, files, URL, in-memory etc.); this could also be used to have original types available (we actually create String from everything, but
we may keep the original type at least when it is requested exactly)
- parsers - config source can read data from some storage; parser can parse data to tree structure. Separation of concerns allows for smaller code to implement a config source
- external mutability - config source can let the config do polling/change watching, and only focus on reading the data (again separation of concerns)
Tomas
|