Skip to content

Conversation

@G8XSU
Copy link
Contributor

@G8XSU G8XSU commented Dec 4, 2024

Allows us to provide config params using ldk-server-config file.

@G8XSU G8XSU requested a review from arik-so December 4, 2024 00:24
args[0]
);
if args.len() < 2 {
eprintln!("Usage: {} config_path", args[0]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the config strategy we wanna pursue? Just passing the file path? A lot of libraries have a multi-layered approach, using a config file, which can be overridden by environment variables, which can be overridden by command-line arguments, and all of that is neatly integrated into man and --help, but typically uses a third-party library.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding multiple levels of config knobs could add confusion,
for now i chose to keep it simple json config without any config reading dependencies.

With more and more config options, cli args won't really be feasible.
Although we could add support for overriding some config-values with env vars in future if needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fair enough. What about defaults? It looks like currently the JSON file needs to have all the fields? Also, does the reading of the JSON file currently allow for additional fields that aren't used by us? Or even comment lines?

Copy link
Contributor Author

@G8XSU G8XSU Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defaults will need to be configured/handled in code.
Yes, currently it needs all the fields to be present, it does allow unknown-fields not being used by us. (added a test)
And doesn't allow comments currently. :(

I did have the option to use something like toml but wasn't sure about crate dependency for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added basic functionality to remove simple single-line comments using '//', tested in tests in latest commit.
Key/value can't contain '//' without escaping since it is a control character.

@G8XSU
Copy link
Contributor Author

G8XSU commented Dec 4, 2024

Pushed fixup commit.

@G8XSU G8XSU requested a review from arik-so December 4, 2024 00:35
@G8XSU
Copy link
Contributor Author

G8XSU commented Dec 4, 2024

Squashed fixups !

@G8XSU G8XSU merged commit ecfe4cc into lightningdevkit:main Dec 4, 2024
1 check passed
@G8XSU G8XSU mentioned this pull request Dec 4, 2024
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants