Skip to content

Add setScheduledExecutorService() to NettyChannelBuilder #10246

@danfaer

Description

@danfaer

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions