CommanderStorm opened a new issue, #719:
URL: https://github.com/apache/arrow-rs-object-store/issues/719
**Is your feature request related to a problem or challenge? Please describe
what you are trying to do.**
Each per-store config key in object_store is currently duplicated across ~8
hand-maintained locations:
- the XxxConfigKey variant,
- its doc + "Supported keys:" list,
- the builder field,
- the AsRef<str> arm,
- the FromStr arm (with all aliases),
- the with_config write arm,
- the get_config_value read arm,
- and the with_<key> convenience setter.
That is a lot of manual sync points which drift independently.
Keeping it in sync by review alone is not realistic if we are honest.
**Describe the solution you'd like**
A small internal proc-macro derive that makes the struct field the single
source of truth:
```rust
#[derive(ObjectStoreConfig)]
#[object_store(config_key = ClientConfigKey, error_path =
crate::Error::UnknownConfigurationKey, error_store =
"HTTP")]
pub struct ClientOptions {
/// Set timeout for the overall request.
timeout: Option<ConfigValue<Duration>>,
#[config(setter = skip)] // hand-written setter clears http2_only too
http1_only: ConfigValue<bool>,
#[config(skip)]
secrete_internal_type: (),
// ... etc
}
```
The code noted above is auto-generated, so the user does not need to deal
with this.
**Describe alternatives you've considered**
I considered
- a `macro_rules!` proc-macro, but i could not quite make the API make the
same "level of sense" as the derive-macro one.
- DataFusion's `config_namespace!` approach which seems overkill. It pulls
in a ConfigField trait + visitor infrastructure for the nested-namespace case
we don't have...
This comes with the downside of needing another crate, not sure if this is a
deal breaker.
**Additional context**
I think a good path for such a thing is to do it in an iterative way, first
starting with `ClientOptions` and many tests to ensure that everything works as
intendet.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]