3434/**
3535 * Provides {@link EventLoopGroup} and {@link ChannelFactory} for {@link NettyNioAsyncHttpClient}.
3636 * <p>
37- * There are three ways to create a new instance.
37+ * There are four ways to create a new instance.
3838 *
3939 * <ul>
4040 * <li>using {@link #builder()} to provide custom configuration of {@link EventLoopGroup}.
4949 *
5050 * <li>Using {@link #create(EventLoopGroup, ChannelFactory)} to provide a custom {@link EventLoopGroup} and
5151 * {@link ChannelFactory}
52+ *
53+ * <li>Using {@link #create(EventLoopGroup, ChannelFactory, ChannelFactory)} to provide a custom {@link EventLoopGroup}, and
54+ * socket and datagram {@link ChannelFactory}'s.
5255 * </ul>
5356 *
5457 * <p>
@@ -78,6 +81,16 @@ public final class SdkEventLoopGroup {
7881 this .datagramChannelFactory = ChannelResolver .resolveDatagramChannelFactory (eventLoopGroup );
7982 }
8083
84+ SdkEventLoopGroup (EventLoopGroup eventLoopGroup , ChannelFactory <? extends Channel > socketChannelFactory ,
85+ ChannelFactory <? extends DatagramChannel > datagramChannelFactory ) {
86+ Validate .paramNotNull (eventLoopGroup , "eventLoopGroup" );
87+ Validate .paramNotNull (socketChannelFactory , "socketChannelFactory" );
88+ Validate .paramNotNull (datagramChannelFactory , "datagramChannelFactory" );
89+ this .eventLoopGroup = eventLoopGroup ;
90+ this .channelFactory = socketChannelFactory ;
91+ this .datagramChannelFactory = datagramChannelFactory ;
92+ }
93+
8194 /**
8295 * Create an instance of {@link SdkEventLoopGroup} from the builder
8396 */
@@ -109,15 +122,30 @@ public ChannelFactory<? extends DatagramChannel> datagramChannelFactory() {
109122 }
110123
111124 /**
112- * Creates a new instance of SdkEventLoopGroup with {@link EventLoopGroup} and {@link ChannelFactory}
125+ * Creates a new instance of SdkEventLoopGroup with {@link EventLoopGroup} and socket {@link ChannelFactory}
113126 * to be used with {@link NettyNioAsyncHttpClient}.
114127 *
115128 * @param eventLoopGroup the EventLoopGroup to be used
116- * @param channelFactory the channel factor to be used
129+ * @param socketChannelFactory the socket channel factory to be used
117130 * @return a new instance of SdkEventLoopGroup
118131 */
119- public static SdkEventLoopGroup create (EventLoopGroup eventLoopGroup , ChannelFactory <? extends Channel > channelFactory ) {
120- return new SdkEventLoopGroup (eventLoopGroup , channelFactory );
132+ public static SdkEventLoopGroup create (EventLoopGroup eventLoopGroup ,
133+ ChannelFactory <? extends Channel > socketChannelFactory ) {
134+ return new SdkEventLoopGroup (eventLoopGroup , socketChannelFactory );
135+ }
136+
137+ /**
138+ * Creates a new instance of SdkEventLoopGroup with {@link EventLoopGroup}, and socket and datagram
139+ * {@link ChannelFactory}'s to be used with {@link NettyNioAsyncHttpClient}.
140+ *
141+ * @param eventLoopGroup the EventLoopGroup to be used
142+ * @param socketChannelFactory the socket channel factory to be used
143+ * @param datagramChannelFactory the datagram channel factory to be used
144+ * @return a new instance of SdkEventLoopGroup
145+ */
146+ public static SdkEventLoopGroup create (EventLoopGroup eventLoopGroup , ChannelFactory <? extends Channel > socketChannelFactory ,
147+ ChannelFactory <? extends DatagramChannel > datagramChannelFactory ) {
148+ return new SdkEventLoopGroup (eventLoopGroup , socketChannelFactory , datagramChannelFactory );
121149 }
122150
123151 /**
@@ -128,8 +156,11 @@ public static SdkEventLoopGroup create(EventLoopGroup eventLoopGroup, ChannelFac
128156 * be thrown for any unknown EventLoopGroup type.
129157 * <p>
130158 * If {@link MultiThreadIoEventLoopGroup} is passed in, {@link NioSocketChannel} and {@link NioDatagramChannel} will be
131- * resolved, regardless of the transport {@link IoHandlerFactory} passed in. This is because it is not possible to
132- * determine the type of transport factory from a given {@link MultiThreadIoEventLoopGroup}.
159+ * resolved, regardless of the transport {@link IoHandlerFactory} set on the {@link MultiThreadIoEventLoopGroup}. This is
160+ * because it is not possible to determine the type of transport factory from a given {@link MultiThreadIoEventLoopGroup}.
161+ * <p>
162+ * To use a {@link MultiThreadIoEventLoopGroup} with a non-Nio transport factory, use
163+ * {@link #create(EventLoopGroup, ChannelFactory, ChannelFactory)}, specifying the socket and datagram channels.
133164 *
134165 * @param eventLoopGroup the EventLoopGroup to be used
135166 * @return a new instance of SdkEventLoopGroup
0 commit comments