-
Notifications
You must be signed in to change notification settings - Fork 1.1k
endpoint resolver/provider #3597
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
2ace84b to
5e53be5
Compare
| @@ -78,6 +79,51 @@ namespace Endpoint | |||
| return SetFromClientConfiguration(static_cast<const Client::ClientConfiguration&>(config)); | |||
| } | |||
|
|
|||
| void BuiltInParameters::SetFromClientConfiguration(const Client::ClientConfiguration& config, const Aws::String& serviceName) | |||
| { | |||
| bool forceFIPS = false; | |||
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 logic is copy and pasted from the other function SetFromClientConfiguration with the exception that we handle the setting of override differently. lets not repeat ourselves and refactor this function so that we dont have copy and pasted code.
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.
Refactor the logic to use a shared SetFromClientConfigurationImpl function
| SetStringParameter(AWS_REGION, "region-not-set"); | ||
| } | ||
| } else if (!serviceName.empty()) { | ||
| Aws::Config::EndpointResolver::EndpointSource(serviceName, config.profileName, config.scheme, *this); |
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.
we shouldnt be passing *this, the objective here is figure out what the endpoint override it, we should not also be mutating self in this call. something along the lines of
OverrideEndpoint(
Aws::Config::EndpointResolver::EndpointSource(serviceName, config),
config.scheme);would be what we want to be doing
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.
Refactor endpointResolver to return an endpoint instead of mutating the config directly
| @@ -26,6 +26,8 @@ namespace Aws | |||
|
|
|||
| virtual void SetFromClientConfiguration(const Client::ClientConfiguration& config); | |||
| virtual void SetFromClientConfiguration(const Client::GenericClientConfiguration& config); | |||
| virtual void SetFromClientConfiguration(const Client::ClientConfiguration& config, const Aws::String& serviceName); | |||
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.
should the non - service name ones have a implementation? why would they not simply call the service name function but with a empty service name?
would this be breaking if someone subclasses BuiltInParameters and they were already overriding SetFromClientConfiguration?
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.
Refactor to use a fallback call instead of implementing new virtual functions
| /** | ||
| * Resolver that sources endpoints and sets them on endpoint providers. | ||
| */ | ||
| class AWS_CORE_API EndpointResolver |
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.
why do we have a class if all the methods are static and we have no members? currently this class is default constructible.
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.
Change this class into a name space instead
| /** | ||
| * Initialize client context parameters from a ClientConfiguration with service name | ||
| */ | ||
| virtual void InitBuiltInParameters(const ClientConfigurationT& config, const Aws::String& serviceName) = 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.
adding a new pure virtual method means that anything else implementing this will break. why not have a default implementation that calls the previous function to preserve backwards compat?
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.
Refactor to use a fallback call with empty service name
| @@ -26,6 +26,8 @@ namespace Aws | |||
|
|
|||
| virtual void SetFromClientConfiguration(const Client::ClientConfiguration& config); | |||
| virtual void SetFromClientConfiguration(const Client::GenericClientConfiguration& config); | |||
| void SetFromClientConfiguration(const Client::ClientConfiguration& config, const Aws::String& serviceName); | |||
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.
why are we not allowing this to be virtual as it was before?
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 me being stupid. Reverted back to virtual with the new impl private function to reduce code duplication.
|
|
||
| // 2) Service-specific environment variable | ||
| { | ||
| Aws::String service = "AWS_ENDPOINT_URL_"; |
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.
why do we create a new variable eachtime? shouldnt this be const and static
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.
Added SERVICE_ENDPOINT_ENV_PREFIX as static const char*, also did the same for GLOBAL_ENDPOINT_ENV_VAR
| service += serviceKey; | ||
| Aws::String fromEnv = Aws::Environment::GetEnv(service.c_str()); | ||
| if (!fromEnv.empty()) { | ||
| AWS_LOGSTREAM_DEBUG(ENDPOINT_RESOLVER_TAG, "Resolved configured endpoint from service-specific environment variable: " << service); |
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.
why are we using DEBUG and TRACE in the same if statement, that means that no matter which log level you choose one or both will be displayed. additionally when you want to know one, but not the other?
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.
Replaced the DEBUG + TRACE with single DEBUG messages that include both the source information and the resolved URL
|
|
||
| const char* ALLOCATION_TAG = "EndpointResolverIntegrationTest"; | ||
|
|
||
| class S3TestClient : public S3Client |
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.
why does this class exist? it looks like it just calls the base class and nothing more
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.
Ops, copied over from s3unit test. Yes there is nothing in the test client being used in this integration test. (Headbucket request is already public).
Removed this class.
| EXPECT_EQ("https://test-bucket.custom-s3.example.com", seenRequest.GetUri().GetURIString()); | ||
| } | ||
|
|
||
| TEST_F(EndpointResolverIntegrationTest, GlobalEnvironmentVariable) |
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 would want a test for GlobalEnvironmentVariableUsedOverProfile so that we validate that global endpoints are chosen over a specific profile endpoint.
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.
Added a GlobalEnvironmentVariableUsedOverProfile test, works as expected with global environment > profile
Issue #, if available:
Description of changes:
Adding an endpoint resolver template to be called in client init to resolve endpoint in order chain
Check all that applies:
Check which platforms you have built SDK on to verify the correctness of this PR.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.