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

Making it easier to supply async http configuration. #274

Merged
merged 1 commit into from
Nov 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Consumer;

/**
* This includes required and optional override configuration required by every async client builder. An instance can be acquired
Expand Down Expand Up @@ -49,4 +50,20 @@ public interface AsyncClientBuilder<B extends AsyncClientBuilder<B, C>, C>
* finished with it, the SDK will only close HTTP clients that it creates.
*/
B asyncHttpConfiguration(ClientAsyncHttpConfiguration asyncHttpConfiguration);

/**
* Configures the HTTP client used by the service client.
*
* Allows just specifying the builder parameters without having to instantiate a builder and call <code>build</code> on it.
* For example
*
* <pre><code>
* builder().asyncHttpConfiguration(b -> b.httpClient(client));
* </code></pre>
*
* @see #asyncHttpConfiguration(ClientAsyncHttpConfiguration)
*/
default B asyncHttpConfiguration(Consumer<ClientAsyncHttpConfiguration.Builder> asyncHttpConfiguration) {
return asyncHttpConfiguration(ClientAsyncHttpConfiguration.builder().apply(asyncHttpConfiguration).build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public interface Builder extends CopyableBuilder<Builder, ClientAsyncHttpConfigu
*/
// This intentionally returns SdkBuilder so that only httpClient or httpClientFactory may be supplied.
SdkBuilder<?, ClientAsyncHttpConfiguration> httpClientFactory(SdkAsyncHttpClientFactory sdkClientFactory);

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.netty.channel.EventLoopGroup;
import java.time.Duration;
import java.util.Optional;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Immutable;
import software.amazon.awssdk.http.SdkHttpConfigurationOption;
import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
Expand Down Expand Up @@ -169,6 +170,16 @@ public interface Builder extends CopyableBuilder<Builder, NettySdkHttpClientFact
*/
Builder eventLoopGroupConfiguration(EventLoopGroupConfiguration eventLoopGroupConfiguration);

/**
* Configuration for the Netty {@link EventLoopGroup} which multiplexes IO events.
*
* @param eventLoopGroupConfiguration consumer that allows a {@link EventLoopGroupConfiguration.Builder} to be mutated.
* @return This builder for method chaining.
* @see #eventLoopGroupConfiguration(EventLoopGroupConfiguration)
*/
default Builder eventLoopGroupConfiguration(Consumer<EventLoopGroupConfiguration.Builder> eventLoopGroupConfiguration) {
return eventLoopGroupConfiguration(EventLoopGroupConfiguration.builder().apply(eventLoopGroupConfiguration).build());
}
}

private static final class DefaultBuilder implements Builder {
Expand Down