-
Notifications
You must be signed in to change notification settings - Fork 909
AsyncClientBuilder cleanup #565
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
Conversation
@@ -140,7 +140,7 @@ public void clientFactoryProvided_ClientIsManagedBySdk() { | |||
public void asyncHttpClientFactoryProvided_ClientIsManagedBySdk() { | |||
TestAsyncClient client = testAsyncClientBuilder() | |||
.region(Region.US_WEST_2) | |||
.asyncHttpClientBuilder(serviceDefaults -> { | |||
.httpClientBuilder((SdkAsyncHttpClient.Builder) serviceDefaults -> { |
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 have to cast it here since SdkDefaultClientBuilder
implements both SdkAsyncClientBuilder
and SdkSyncClientBuilder
and has overloads of httpClientBuilder
for async and sync. I think this is fine as SdkDefaultClientBuilder
is protected api
|
||
/** | ||
* Sets the {@link EventLoopGroupFactory} which will be used to create the {@link EventLoopGroup} for the Netty | ||
* Sets the {@link SdkEventLoopGroup.Builder} which will be used to create the {@link SdkEventLoopGroup} for the Netty |
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.
How many event loops could an event loop group if an event loop could group loops? ;)
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.
Haha, what a tongue twister!
public static Builder builder() { | ||
return new DefaultBuilder(); | ||
private ChannelFactory<? extends Channel> resolveChannelFactory() { | ||
// Currently we only support NioEvenLoopGroup |
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.
Missing t
|
||
private final EventLoopGroup eventLoopGroup; | ||
private final ChannelFactory<? extends Channel> channelFactory; | ||
private final Integer numberOfThreads; |
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.
Do we need to have fields for number of threads and thread factory or can we just use them to create an event loop group at build time?
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 was thinking customers can retrieve the value by calling numberOfThreads()
. But that's not necessary and can be confusing to customers who use SdkEventLoopGroup.create
method to create the class. Removed.
* @param eventLoopGroup the event loop group to determine the {@link ChannelFactory} for | ||
* @return A {@link ChannelFactory} instance for the given event loop group. | ||
*/ | ||
public static ChannelFactory<? extends Channel> resolveSocketChannelFactoryClass(EventLoopGroup eventLoopGroup) { |
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.
Do we still need 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.
Good catch. Updated SharedSdkEventLoopGroup
to store SdkEventLoopGroup
so that we can get default channel factory associated with the default event loop group.
* @param channelFactory the channel factor to be used | ||
* @return a new instance of SdkEventLoopGroup | ||
*/ | ||
public static SdkEventLoopGroup create(EventLoopGroup eventLoopGroup, ChannelFactory<? extends Channel> channelFactory) { |
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.
Maybe an overload for the channel class that creates the reflective factory
2cca22a
to
3d03c6a
Compare
…oupLoop to allow users provide both EventGroupLoop and ChannelFactory.
3d03c6a
to
7e4fc08
Compare
…65ef9b07 Pull request: release <- staging/6386348e-edae-4494-89cf-efc865ef9b07
Various AsynClientBuilder clean up.
async
prefix in the builder(but we are gonna need to cast the httpClient builder inSdkDefaultClientBuilder
see comments in the PR)SdkEventLoopGroup
as wrapper class to holdEventLoopGroup
andChannelFactory
to be used for Netty client.Here's how
NettyNioAsyncHttpClient
configuration looks like:Notes
SdkEventLoopGroup
SdkEventLoopGroup.create(eventLoopGroup, channelFactory)
SdkEventLoopGroup.builder()
and the builder doesn't have eventLoopGroup() interface defined.This might be confusing to customers and I considered moving the builder to a different class but I find keeping them in the same class helps discoverability.
.eventLoopGroupBuilder()
is taking the builder class as parameter