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

Support specifying features with @service #457

Merged
merged 3 commits into from
Sep 28, 2021
Merged

Support specifying features with @service #457

merged 3 commits into from
Sep 28, 2021

Conversation

omus
Copy link
Member

@omus omus commented Sep 24, 2021

While working on #384 I encountered a situation where the change I was making was breaking so in order to have to make a major release I wanted to make the change opt-in. Unfortunately doing that would result in every single AWS.jl API call being modified to opt-in to the new behaviour making updating quite tedious.

The @service feature support added in this PR allows end users to opt-in to new behaviour when using the @service macro (e.g. @service S3 my_new_feature=true). This interface is much more convenient and probably is a pattern we want to use for incorporating future behaviour. Currently this PR defines no features. Additionally for low-level API calls I've introduced the set_features function (e.g. set_features(::Service; my_new_feature=true)) which allows for setting the feature set to be used for a service instance.

The only issue I can think of with this is if an end user makes use of multiple @service calls to the same service in the same module then the last call will define the behaviour. As doing this will result in a module being redefined I don't think this is a situation anyone will notice.

@omus omus requested a review from mattBrzezinski September 24, 2021 14:31
@omus
Copy link
Member Author

omus commented Sep 24, 2021

bors try

bors bot added a commit that referenced this pull request Sep 24, 2021
@bors
Copy link
Contributor

bors bot commented Sep 24, 2021

try

Build failed:

@omus
Copy link
Member Author

omus commented Sep 24, 2021

There's a expression corner case on Julia 1.4 and below which I didn't capture in my tests.

@omus
Copy link
Member Author

omus commented Sep 24, 2021

bors try

bors bot added a commit that referenced this pull request Sep 24, 2021
test/utilities.jl Outdated Show resolved Hide resolved
@bors
Copy link
Contributor

bors bot commented Sep 24, 2021

@omus
Copy link
Member Author

omus commented Sep 24, 2021

Last change just fixes formatting so I won't bother re-running bors

@omus
Copy link
Member Author

omus commented Sep 24, 2021

I can apply the fixups prior to merging once approved

@bors
Copy link
Contributor

bors bot commented Sep 24, 2021

src/AWS.jl Outdated Show resolved Hide resolved
@omus
Copy link
Member Author

omus commented Sep 24, 2021

bors try

bors bot added a commit that referenced this pull request Sep 24, 2021
@bors
Copy link
Contributor

bors bot commented Sep 24, 2021

@omus
Copy link
Member Author

omus commented Sep 24, 2021

In experimenting with this in #458 it's probably sensible to have the low-level API also make use of features

@omus
Copy link
Member Author

omus commented Sep 24, 2021

In experimenting with this in #458 it's probably sensible to have the low-level API also make use of features

As the low-level API is from AWSServices.jl which is included in AWS.jl I can't use the same trick here. Not a big deal but that does bring up an issue for #384: #384 (comment).

@omus
Copy link
Member Author

omus commented Sep 24, 2021

In experimenting with this in #458 it's probably sensible to have the low-level API also make use of features

I found a decent solution to this problem: 94f7f56. I'll bring that change into this PR once I get it all working

@omus
Copy link
Member Author

omus commented Sep 24, 2021

Rebasing fixups

@omus omus force-pushed the cv/service-features branch from dd90a1c to cccc439 Compare September 24, 2021 21:33
@omus
Copy link
Member Author

omus commented Sep 24, 2021

bors try

bors bot added a commit that referenced this pull request Sep 24, 2021
@bors
Copy link
Contributor

bors bot commented Sep 24, 2021

Comment on lines 147 to 148
$formatted_function_name($(join(req_keys, ", ")); aws_config::AbstractAWSConfig=global_aws_config()) = $service_name(\"$method\", \"$request_uri\", $params_headers_str; aws_config=aws_config, features=SERVICE_FEATURES)
$formatted_function_name($(join(req_keys, ", ")), params::AbstractDict{String}; aws_config::AbstractAWSConfig=global_aws_config()) = $service_name(\"$method\", \"$request_uri\", Dict{String, Any}(mergewith(_merge, $params_headers_str, params)); aws_config=aws_config, features=SERVICE_FEATURES)
Copy link
Member Author

Choose a reason for hiding this comment

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

An alternative approach would be to define the following right after the generated using statements:

const $service_name = set_features(AWS.AWSServices.$service_name; SERVICE_FEATURES...)

This would reduce the changes to the generated code at the cost of having to unpack the ServiceWrapper. Probably the current approach in the PR is the right one.

@omus
Copy link
Member Author

omus commented Sep 25, 2021

bors try

bors bot added a commit that referenced this pull request Sep 25, 2021
@bors
Copy link
Contributor

bors bot commented Sep 25, 2021

@omus
Copy link
Member Author

omus commented Sep 27, 2021

I'll mention that #460 wouldn't play well with the high-level service features as this PR currently implements them. I think the way these two things could compose is that AWS.jl would have the high-level services as submodules. If you want to use the high-level services with non-default features you would need to use the @service macro (may be a macro with a different) to do that.

@mattBrzezinski
Copy link
Member

Taking this out of our discussion from Slack before it gets lost into the void. This seems like a good step forward with allowing for breaking changes to occur in this package without releasing a new major version. When we eventually get to N amount of breaking changes, or just choose to make a new release it should be easy enough to incorporate. Especially since work in this package is kind of sporadic.

The code itself LGTM! The trade off of more generated code vs. unpacking makes sense, no one will be looking at the generated code regardless.

@omus omus mentioned this pull request Sep 27, 2021
@omus omus force-pushed the cv/service-features branch from edcd935 to 10b07ea Compare September 28, 2021 04:16
@omus
Copy link
Member Author

omus commented Sep 28, 2021

Rebased to resolve conflict and I squashed some commits

@omus
Copy link
Member Author

omus commented Sep 28, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented Sep 28, 2021

@bors bors bot merged commit 564f9c5 into master Sep 28, 2021
@bors bors bot deleted the cv/service-features branch September 28, 2021 04:25
bors bot added a commit that referenced this pull request Sep 29, 2021
384: Use `AWS.Response` to handle streaming/raw/parsing r=omus a=omus

The idea is to use a struct in AWS.jl that can be used to handle the automatic parsing that is currently used to turn XML/JSON into a dict while also giving the option of accessing the raw output as a string or stream without all the keywords currently needed to be specified.

Depends on:
- #457

Related:
- #346
- #348
- #438

Closes:
- #224
- #433
- #468 (when using `use_response_type` the passed in I/O is not closed)
- #471
- #433

Update: The tests in this PR run using the deprecated behaviour. Mainly I did that here to prove this change is non-breaking. For the updated tests see #458 

Co-authored-by: Curtis Vogt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants