Skip to content
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

refactor: assorted FlightSqlServiceClient improvements #3788

Merged

Conversation

crepererum
Copy link
Contributor

Which issue does this PR close?

-

Rationale for this change

Assorted FlightSqlServiceClient improvements:

  • TLS config: Do NOT alter existing method signatures if the TLS feature is enabled. Features should be purely additive in Rust. Instead use a new method to pass TLS configs. The config is now passed as ClientTlsConfig to allow more flexibility, e.g. just to use TLS w/o any client certs.
  • token handlng: Allow the token to be passed in from an external source. The auth spec is super flexibility ("application-defined") and we cannot derive a way to determine the token in all cases. The current handshake-based mechanism is OK though. Also make sure the token is used in all relevant methods.
  • headers: Allow users to pass in additional headers. This is helpful for certain applications.

What changes are included in this PR?

See list above.

Are there any user-facing changes?

Breaking slight changes in the FlightSqlServiceClient interface.

@github-actions github-actions bot added arrow Changes to the arrow crate arrow-flight Changes to the arrow-flight crate labels Mar 2, 2023
- **TLS config:** Do NOT alter existing method signatures if the TLS
  feature is enabled. Features should be purely additive in Rust.
  Instead use a new method to pass TLS configs. The config is now passed
  as `ClientTlsConfig` to allow more flexibility, e.g. just to use TLS
  w/o any client certs.
- **token handlng:** Allow the token to be passed in from an external
  source. The [auth spec] is super flexibility ("application-defined")
  and we cannot derive a way to determine the token in all cases. The
  current handshake-based mechanism is OK though. Also make sure the
  token is used in all relevant methods.
- **headers:** Allow users to pass in additional headers. This is
  helpful for certain applications.

[auth spec]: https://arrow.apache.org/docs/format/Flight.html#authentication
@crepererum crepererum force-pushed the crepererum/flight_sql_client_improvements branch from 9c38019 to 8a118bd Compare March 2, 2023 13:19
@alamb alamb requested a review from avantgardnerio March 2, 2023 14:46
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

I think this is an improvement -- thank you @crepererum . However, I think it would be good if @avantgardnerio could offer his opinions too prior to merge

client_ident: Identity,
server_ca: Certificate,
domain: &str,
pub async fn new_with_tls_endpoint(
Copy link
Contributor

Choose a reason for hiding this comment

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

what do you think about removing all tls configuration out of the actual client and instead add a doc example that shows how to configure the client for TLS?

I feel like simply having new(channel: Channel) would be the simplest API and all the rest of the code in this function could be turned into doc comments. This would likely be simpler to use, have less code, and be easier to configure with arbitrary configurations (like keepalives, etc)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At the moment we also use a very opinionated Endpoint config (see fn endpoint). If we keep that then I would at least like to offer a way to configure a TLS client that is in line with that presets. However we may also just remove the opinionated endpoint setup altogether and ONLY present a single constructor that takes channel. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

That is what I would recommend and what I started to do in https://github.com/apache/arrow-rs/pull/3401/files#diff-f9c519f51ac059c26fa8fb28b174ebf8d66169690758b6b8a53bcf13ec6acb58R132

Let me see if I can update that PR to get it looking better ...

Copy link
Contributor

Choose a reason for hiding this comment

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

(that PR is too far gone, so I closed it). But I think the idea is still a good one (take only an Endpoint) -- and it is consistent with the FlightClient: https://docs.rs/arrow-flight/34.0.0/arrow_flight/client/struct.FlightClient.html#method.new

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 can change that tomorrow morning (central EU).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done (also simplified example and CI around it)

@@ -141,14 +132,27 @@ impl FlightSqlServiceClient {
self.flight_client
}

/// Set auth token to the given value.
pub fn set_token(&mut self, token: String) {
self.token = Some(token);
Copy link
Contributor

Choose a reason for hiding this comment

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

So this will then propagate to all calls? 😍

@crepererum
Copy link
Contributor Author

crepererum commented Mar 3, 2023

Windows build fails due to rust-lang/socket2#408

Update: version was yanked, re-pushed to retrigger the build.

Just accept a channel and let the caller set it up to their liking.
Simplify example as well so that we no longer do totally different
things under different features (since features shall be additive).
Instead use a single example.
@crepererum crepererum force-pushed the crepererum/flight_sql_client_improvements branch from ea826b1 to fe36584 Compare March 3, 2023 11:06
@tustvold tustvold added the api-change Changes to the arrow API label Mar 3, 2023
@tustvold tustvold merged commit 40e2874 into apache:master Mar 3, 2023
@ursabot
Copy link

ursabot commented Mar 3, 2023

Benchmark runs are scheduled for baseline = b9fcd7f and contender = 40e2874. 40e2874 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

})?;
Ok(Self::new(channel))
}

/// Creates a new FlightSql client that connects to a server over an arbitrary tonic `Channel`
pub fn new(channel: Channel) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-change Changes to the arrow API arrow Changes to the arrow crate arrow-flight Changes to the arrow-flight crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants