New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to pass a configuration file to Meilisearch #2558
Comments
|
Also pinging @meilisearch/integration-team who can be interesting for their devops tools |
|
Hey, this is a really cool project, and I would like to contribute to this is possible. As this issue is open, can I try to work on it? As far as I understand, https://github.com/meilisearch/meilisearch/blob/main/meilisearch-http/src/lib.rs#L30 sets up the meilisearch with its options, so my thought for this is to declare a struct with all cmd line option, parse it using toml as suggested, and then in the set up function, conditionally give cmd opts or config file opts, as by the priority mentioned. I might even declare a new struct for the purpose of combining the config file ind cmd opts, which will be given to the set up function instead of giving it the clap parsed opts directly. The issues that I'm currently thinking of in this are :
What do you think about the above? Can I work on this issue, or should I check something else first? Thanks :) |
|
Hello, @YJDoc2 thanks for your interest!
For your first point, clap is already handling the last part of the problem; env < cli. For the second point, I would like to keep a single structure for both clap and the config file. I don’t know if it’s possible/easy but if you try to tackle this issue, I would like you to try it, and if it doesn’t work explain to us why |
|
Hey @irevoire , one of the issues for using the same struct for toml and opts is there are some fields set as Another issue is that the above spec suggests that the config file should ideally group the keys in sections by type :
But as the fields in opts structs are separate, they cannot be grouped in toml. For that to be possible, the similar options must be moved into a struct which then appear as a section in the toml ; but that will cause changes in all places where those variables are used. Also, to get clarification,
Should the default be Thanks :) |
Yes, that's perfect
Don't you think you can make your multiple structures but still make thing shows correctly in clap with a bunch of
I don't think we're going to auto-import a config file. Thus you'll need to add a cli option to import the config file, and its name can be anything |
It might be possible with flatten and manual naming, but it will also do changes in code code where these are being used, as instead of |
|
Would it be too much work, and would it be interesting, to support both YAML and TOML? YAML is the most widely used format on cloud-native applications. But TOML is indeed way easier to parse, and we don't need to handle the whitespace hell of YAML files. Just wondering if being able to handle both would make life easier for many, or if it would introduce unnecessary complexity for the development/ maintenance of the feature! |
|
Hello @eskombro I pinged the cloud team on this discussion to discuss it, feel free to add anything you would need |
Discussed with @gmourier and following this information: meilisearch/product#85 (comment)
We want Meilisearch to accept a configuration file that would be an alternative to the command-line options you can set when launching Meilisearch, for instance
Requirements
Format
The file format should be
TOML.Priority order
Configuration file < Env variables < command-line options
It means the options in the configuration file can be overwritten by the environment variable set (if they exist) and that can be themself overwritten by the command-line options (if they exist)
Example
With this config file
and with the following variables and command-line options:
The final values kept by Meilisearch will be
no_analytics = trueset in the config filefilepath3because--db-path=./filepath3has been set as command line options../filepath1and./filepath2are ignored.127.0.0.1:7702because set as an environment variable. The value in the config file (127.0.0.1:7701) is ignored.abcd1234set in the command-line option. The value in the config file is ignored (thisisasuper1337masterkey@@@).Config file content
The config file will have sections gathering the same kind of variable.
Example:
Config file command line
The default config file name is
config.tomland will be retrieve by Meilisearch by default in the current working directoryYou can pass the config file as command-line option
meilisearch --config-file-path="./config.toml"So the default value of
config-file-pathis./meili_config.toml.This means by default, Meilisearch will try to read
./config.toml.If no
./config.tomlfile is found and no--config-file-pathoption is passed, Meilisearch does not throw any error.Errors (bonus)
We need to parse and display clear errors message for the configuration scheme. e.g. https://docs.rs/miette/latest/miette/
Implementations
We could probably start by using the toml crate and declare a struct with a simple derive on it. We could start the job in the options.rs file or maybe create a new one specifically for this config file.
If you have any questions regarding the feature or the implementation, please let us know about this issue! Every feedback or questions are welcome!
For Meili people
A spec will be open once we have implemented it. Some changes can still be applied, we need to see the final implementation to create the spec.
Since we let this issue (so far) to the community, we don't know yet in which release this new feature will be available (at minimum v0.29.0, not before).
Ping @meilisearch/cloud-team @meilisearch/docs-team who can be concerned by this issue.
The text was updated successfully, but these errors were encountered: