-
Notifications
You must be signed in to change notification settings - Fork 82
Parametrize InfluxDB Version #167
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea behind this change, but I am not sure if the current approach, i.e. always having a version attached, is necessary. We should probably have an AnyVersion
-like type that works with any influxdb server version we support. This, of course, would not support features that don't work with all influxdb server versions, but from experience hosting services that connect to postgres, I expect them to work with multiple recent versions without recompilation.
pub(crate) url: Arc<String>, | ||
pub(crate) parameters: Arc<HashMap<&'static str, String>>, | ||
pub(crate) token: Option<String>, | ||
pub(crate) client: HttpClient, | ||
pub(crate) client: H, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this change makes much sense, given that we already decided to sunset surf support in #147
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was thinking of doing #147 first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, still not sure why the generic?
I was thinking about things like parametrized queries, where we can build a V3 query serializer / client that is capable of doing that and fallback to one which does not do that on v1/v2. Is that possible with your approach? I am open to solving this another way or better, this is just the first thing I came up with. |
If you bake it into the type signature, you cannot change that at runtime. If you want to adjust the behaviour at runtime, I'm not sure why you'd bake it into the type signature? Your approach might make sense, but I don't see it yet |
By using the marker, we can implement something like this. Unless it's a
|
Yes. But, what if I want to write an application that supports all versions of influxdb, and wants to set the retention policy if supported? In that case, I'd much rather have the method always available, and return something like |
Got it, that indeed makes sense. After #168 merged, I will refactor this. |
Description
More and more feature keep getting added or wished for that depend on specific versions of InfluxDB (#132, #136, #165). This PR creates a
PhantomData
version field in the client. That way, we can implement traits for version specific features and do not mix feature that might be incompatible with a connected database.I am looking for first feedback about this design / approch before I port over any other version related code.
Checklist
cargo fmt --all
cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,reqwest-client-rustls -- -D warnings
cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,hyper-client -- -D warnings
cargo doc2readme -p influxdb --expand-macros