Skip to content

Add support for endpoint trait #795

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

Merged
merged 3 commits into from
Nov 28, 2018
Merged

Conversation

varunnvs92
Copy link
Contributor

@varunnvs92 varunnvs92 commented Nov 4, 2018

Fixed: [WIP] APIs with path params are being resolved incorrectly. Will investigate

Ready to merge

@varunnvs92 varunnvs92 force-pushed the varunkn/SupportEndpointHostTrait branch 5 times, most recently from aa52413 to bad6d30 Compare November 9, 2018 02:44
@@ -104,7 +105,8 @@ protected final SdkClientConfiguration mergeChildDefaults(SdkClientConfiguration
.option(AwsAdvancedClientOption.ENABLE_DEFAULT_REGION_DETECTION, true)
.option(AwsClientOption.CREDENTIALS_PROVIDER, DefaultCredentialsProvider.create())
.option(SdkClientOption.RETRY_POLICY, AwsRetryPolicy.defaultRetryPolicy())
.option(AwsClientOption.SERVICE_SIGNING_NAME, signingName()));
.option(AwsClientOption.SERVICE_SIGNING_NAME, signingName())
.option(SdkAdvancedClientOption.DISABLE_HOST_PREFIX_INJECTION, false));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this an option?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO it is an advanced option and not common use case to set it, so I made it an option instead of directing exposing it in ClientOverrideConfiguration. Do you think it makes more sense to expose it as top level member in ClientOverrideConfiguration?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can it not be an option at all?

Copy link
Contributor

Choose a reason for hiding this comment

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

Talked offline. It can be useful in testing.

request.setEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT));


request.setEndpoint(resolveEndpoint(clientConfiguration, executionParams.hostPrefixExpression()));
Copy link
Contributor

Choose a reason for hiding this comment

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

This actually changes a bit with the marshaller refactor. I'm curious to get your opinion on this, right now I'm passing the client configured endpoint to the marshaller and setting the endpoint there. I need to do that because SdkHttpFullRequest can't be built without an endpoint. We could a couple of things I think

  1. Relax constraints in SdkHttpFullRequest to not require endpoint on build so we can open it back up later and add endpoint
  2. Change marshallers to produce a SdkHttpFullRequest.Builder and fill in the endpoint and build later on in the request lifecycle
  3. Somehow get the operation level endpoint to the marshaller and set it there
  4. Continue to just set the client level endpoint knowing that it may be overwritten later

Thoughts?

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 am leaning towards 4.

  1. Change marshallers to produce a SdkHttpFullRequest.Builder and fill in the endpoint and build later on in the request lifecycle

I think its better to pass built objects to avoid any mutability concerns

  1. Somehow get the operation level endpoint to the marshaller and set it there

Have to do it for each protocol. Don't like it

  1. Continue to just set the client level endpoint knowing that it may be overwritten later

I like this as we get marshalled request and we can construct a new request (with new endpoint) if host prefix is set. As we don't reuse the marshalled request at any place other than BaseClientHandler, it seems safe and modification happen at single place.
If we are choosing between 4 and 1, relaxing constraints doesn't give any advantage and 4 seems ideal.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed offline. Going to keep the logic to update endpoint in BaseClientHandler instead of moving to marshallers as we need to pass more information every time we need to support a feature updating endpoint (like endpoint discovery).

@varunnvs92 varunnvs92 force-pushed the varunkn/SupportEndpointHostTrait branch 2 times, most recently from 4886cb0 to 831f9e9 Compare November 16, 2018 20:54
@varunnvs92
Copy link
Contributor Author

Addressed all the comments

@varunnvs92
Copy link
Contributor Author

APIs with path params are being resolved incorrectly. Will investigate

@varunnvs92 varunnvs92 force-pushed the varunkn/SupportEndpointHostTrait branch 4 times, most recently from aa6f549 to 700ed9c Compare November 27, 2018 22:06
@@ -145,6 +146,9 @@ public final String serviceName() {
@Override
public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) {
try {
String hostPrefix = "{StringMember}-foo.";
Copy link
Contributor

Choose a reason for hiding this comment

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

Is hostPrefix ever used? Also it seems simpler to me to just replace the placeholders rather than change to %s and do a string.format.

Something like

String resolvedHostExpression = "{StringMember}-foo."
.replace("{StringMember}", aPostOperationRequest.stringMember());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1
#883

@varunnvs92 varunnvs92 force-pushed the varunkn/SupportEndpointHostTrait branch from 700ed9c to d9616a5 Compare November 28, 2018 04:08
@varunnvs92 varunnvs92 merged commit 918aba2 into master Nov 28, 2018
@varunnvs92 varunnvs92 deleted the varunkn/SupportEndpointHostTrait branch November 28, 2018 04:39
aws-sdk-java-automation added a commit that referenced this pull request Apr 8, 2020
…5492b48f

Pull request: release <- staging/dd963b91-03ee-4cec-9700-640a5492b48f
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.

3 participants