Is your feature request related to a problem?
The NettyTransportFactory.getScheduledExecutorService() method returns the EventLoopGroup used for scheduling timeout tasks and other operations. However, the current implementation of EventLoopGroup.schedule() calls EventLoopGroup.next(), which moves the index of the current event loop to the next position. This behavior leads to unpredictable event loop selection for NettyClientTransport, potentially causing multiple Netty channels to share the same event loop, even if the number of event loops in the group is greater than the number of channels.
Describe the solution you'd like
I propose adding a setter for the ScheduledExecutorService in the NettyChannelBuilder. If a user-defined ScheduledExecutorService is set, it will be returned by NettyTransportFactory.getScheduledExecutorService() and used for scheduling tasks. As a result, the call to EventLoopGroup.next() will exclusively occur from NettyClientTransport.start().
Describe alternatives you've considered
An alternative solution would be to use a Composite EventLoopGroup that handles EventLoopGroup.schedule() differently. However, implementing this solution is not straightforward due to the EpollEventLoopGroup being a final class.
Is your feature request related to a problem?
The
NettyTransportFactory.getScheduledExecutorService()method returns theEventLoopGroupused for scheduling timeout tasks and other operations. However, the current implementation ofEventLoopGroup.schedule()callsEventLoopGroup.next(), which moves the index of the current event loop to the next position. This behavior leads to unpredictable event loop selection forNettyClientTransport, potentially causing multiple Netty channels to share the same event loop, even if the number of event loops in the group is greater than the number of channels.Describe the solution you'd like
I propose adding a setter for the
ScheduledExecutorServicein theNettyChannelBuilder. If a user-definedScheduledExecutorServiceis set, it will be returned byNettyTransportFactory.getScheduledExecutorService()and used for scheduling tasks. As a result, the call toEventLoopGroup.next()will exclusively occur fromNettyClientTransport.start().Describe alternatives you've considered
An alternative solution would be to use a Composite EventLoopGroup that handles
EventLoopGroup.schedule()differently. However, implementing this solution is not straightforward due to theEpollEventLoopGroupbeing afinal class.