-
Notifications
You must be signed in to change notification settings - Fork 448
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
Encode request payload optionally with Gzip #1615
Conversation
Rebase rusoto master
merge version 42
@@ -35,6 +36,7 @@ impl Client { | |||
let inner = Arc::new(ClientInner { | |||
credentials_provider: Some(Arc::new(credentials_provider)), | |||
dispatcher: Arc::new(dispatcher), | |||
content_encoding: Default::default(), |
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.
what if we move the content_encoding
to the Client
and pass it to Inner
methods only when needed.
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 checked it out and I need to call encode()
in SignAndDispatch
trait and ClientInner
implements it, not Client
.
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.
So than may be add new constructor, or may be a builder. This way we don't need to mutate it.
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 have implemented in that way, it is better because we don't need to regenerate other services. Take a look at the new version.
rusoto/core/src/lib.rs
Outdated
@@ -35,6 +35,7 @@ pub extern crate rusoto_credential as credential; | |||
extern crate serde; | |||
#[macro_use] | |||
extern crate serde_derive; | |||
pub extern crate flate2; |
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.
What do you think about it? People will access it as rusoto_core::flate2
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 we need to make it pub
. If people need it they will defined their own dependencies.
rusoto/core/src/client.rs
Outdated
|
||
/// Set content_encoding type for http requests which will compress request payload accordingly | ||
pub fn set_http_content_encoding(&mut self, content_encoding: ContentEncoding) { | ||
let inner = Arc::get_mut(&mut self.inner) |
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.
this is the main problem I see - sometimes it will succeed, sometimes it will panic, depending on the number of references.
@@ -28,28 +28,28 @@ fn should_describe_directories() { | |||
fn should_conditional_forwarders() { | |||
let client = DirectoryServiceClient::new(Region::UsWest2); | |||
let mut request = DescribeConditionalForwardersRequest::default(); | |||
request.directory_id = "d-11111aaaaa".to_string(); | |||
request.directory_id = "d-11111aaaaa".to_string(); |
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.
these are from cargo fmt
Hey @matthewkmayer @iliana could you guys check it out? |
ping |
rusoto/core/Cargo.toml
Outdated
@@ -42,6 +42,7 @@ time = "0.1.35" | |||
tokio = "0.1.7" | |||
tokio-timer = "0.2.6" | |||
xml-rs = "0.8" | |||
flate2 = "1.0" |
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.
Can we change this dependency so it's only brought in when the encoding
flag is active?
flate2 = { version = "1.0", optional = true }
rusoto/core/Cargo.toml
Outdated
@@ -63,6 +64,7 @@ serde_test = "1.0.1" | |||
|
|||
[features] | |||
default = ["native-tls"] | |||
encoding = [] |
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.
To achieve the behavior in the comment above, this can be changed to encoding = ["flate2"]
to pull in the crate as needed. 👍
integration_tests/Cargo.toml
Outdated
@@ -24,6 +24,9 @@ debug = false | |||
path = "../rusoto/core" | |||
default-features = false | |||
|
|||
[dependencies.rusoto_credential] | |||
path = "../rusoto/credential" |
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 think we can skip this change, since rusoto_core reexports rusoto_credential. use rusoto_core::credential::DefaultCredentialsProvider;
should do the trick. 👍
let mut encoder = GzEncoder::new(Vec::<u8>::new(), Compression::new(*level)); | ||
encoder | ||
.write_all(payload) | ||
.expect("Request payload was not written to encoder."); |
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.
While it's been my experience flate2
doesn't return errors in real use, what do you think about returning the errors instead of using unwrap
or expect
? That way we can pass the errors back up to the client and the caller can handle it from there.
I'm okay with that change being done in a followup PR, as this one is close to being done. 😄
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.
Thanks for the review, I'll address it on the next PR :)
Thanks for sticking with this! It's only got a couple changes to make, per my comments, and it should be good to go. 🎉 |
* master: (162 commits) Fix doc test for Secret's Debug impl. Add rusoto#1615 to changelog Fixes - Changes according to feedback from Iliana - Fix hyperlink in documentation - Changes based on feedback from first review. Updated changelog Add custom dependency for STS (didn't realise that I cannot just change the dependencies in Cargo.toml). Added new DefaultCredentialsProvider implementation in rusoto_sts which supports more credentials sources. Implemented WebIdentityProvider to support IAM Roles for Kubernetes Service Accounts (https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html). update changelog for fix sns api fix ignore key-value order Limit publishing rate by reducing parallel compilations. add custom test for sns api This clippy lint should be ignored in crategen. Set rusoto_mock to same version as rusoto_core in crategen. Publish crates in alphabetical order. Don't run doctests on nightly. Remove flate2 dependency from core Implement encoding client with a separate constructor ...
Allow content encoding for compressing request payloads with Gzip
Continuation of #1469 PR discussion.
I'll generate services in separate commit.
Added an integration test for CloudWatch logs to support the use case also.