Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for loading configuration options from a config file besides using the CLI arguments.
It's possible to use both side by side, and in that case the CLI options take precedence and override the config file options. Default values for CLI flags are used where applicable.
Values are determined by (less to more important):
This might not be the final version, it might evolve further if it turns out to be too clunky for use from the dev side (user is fine IMO).
Complication comes from the fact that the CLI flags are flat (e.g.
--address 127.0.0.1 --port 9000 --runtime-path ~/blockless/runtime
), compared to the file which is structured. Currently the config file has four sections -log
,connectivity
,worker
andhead
. In the example above, theaddress
andport
options live in theconnectivity
section, whereas theruntime-path
lives in theworker
section.I didn't want to go the typical route of the group being embedded in the CLI flag (
--connectivity-address, --connectivity-port, --worker-runtime-path
) as it's pretty noisy. Instead, we define the group in which the flag lives and we map values to sections in code. This mapping is done in flags.go.Example of a config file:
For a more detailed reference of the config file, I added example.yaml.