Skip to content

New gRPC channel manager#1400

Draft
rcameronm wants to merge 7 commits into
NationalSecurityAgency:mainfrom
rcameronm:Create-different-gRPC-channel-managers
Draft

New gRPC channel manager#1400
rcameronm wants to merge 7 commits into
NationalSecurityAgency:mainfrom
rcameronm:Create-different-gRPC-channel-managers

Conversation

@rcameronm

@rcameronm rcameronm commented May 26, 2026

Copy link
Copy Markdown
Collaborator

This pull request refactors the gRPC connection management system by replacing the old connection pooling approach with a new ChannelManager abstraction. The main goal is to provide a more flexible and configurable way to manage gRPC channels, making it easier to customize channel behavior and support different channel management strategies. The most significant changes are outlined below.

Core Refactor: Channel Management Abstraction

  • Introduced a new abstract base class ChannelManager in emissary.grpc.channel, which centralizes configuration and management of gRPC ManagedChannel connections. This class supports various channel options (keep-alive, load balancing, message sizes) and provides a factory method for instantiating subclasses via reflection. (src/main/java/emissary/grpc/channel/ChannelManager.java)

  • Updated GrpcRoutingPlace to use ChannelManager instead of the previous ConnectionFactory and pooling approach. Each target now has a dedicated GrpcInvoker backed by a ChannelManager, improving configurability and resource management. (src/main/java/emissary/grpc/GrpcRoutingPlace.java) [1] [2] [3] [4] [5]

Configuration and API Updates

  • Added support for specifying the channel manager class via the GRPC_CHANNEL_MANAGER_CLASS_NAME configuration key, defaulting to PooledChannelManager. This allows for easy swapping or customization of channel management strategies. (src/main/java/emissary/grpc/GrpcRoutingPlace.java) [1] [2]

  • Updated JavaDoc and documentation references in both GrpcConnectionPlace and GrpcRoutingPlace to point to ChannelManager for channel configuration, replacing references to the deprecated ConnectionFactory. (src/main/java/emissary/grpc/GrpcConnectionPlace.java, src/main/java/emissary/grpc/GrpcRoutingPlace.java) [1] [2]

Simplification and Cleanup

  • Removed all usage of Apache Commons Pool and the associated ConnectionFactory and PoolException classes from GrpcRoutingPlace, simplifying the code and reducing dependencies. (src/main/java/emissary/grpc/GrpcRoutingPlace.java) [1] [2] [3] [4]

  • Refactored internal lookup and invocation logic in GrpcRoutingPlace to use the new invokerTable and getInvoker() method, streamlining how gRPC calls are routed and executed. (src/main/java/emissary/grpc/GrpcRoutingPlace.java) [1] [2] [3]

These changes collectively modernize the gRPC connection infrastructure, making it more modular, configurable, and easier to extend or maintain.

@rcameronm rcameronm force-pushed the Create-different-gRPC-channel-managers branch from 59f2b3a to 4ece198 Compare May 26, 2026 14:00
@cfkoehler cfkoehler added this to the v8.46.0 milestone May 27, 2026
@rcameronm rcameronm force-pushed the Create-different-gRPC-channel-managers branch from c2bb678 to 66d2625 Compare June 5, 2026 14:02
}

public static ChannelManager ofSubClass(
Class<? extends ChannelManager> clz, String host, int port, Configurator configG, ChannelCredentials credentials) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attached is a patch to replace reflection with a factory design pattern. Any class subclass without the proper method signature will throw a compile error.
0001-replace-reflection-with-a-factory.patch

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been using this reflection pattern for awhile. Should I make some new tickets to change them to this factory design pattern as well?

@fbruton fbruton Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend it. It will improve maintainability.

@jpdahlke jpdahlke added the rebase Things have happened and now a rebase is needed label Jun 23, 2026
@rcameronm rcameronm force-pushed the Create-different-gRPC-channel-managers branch from 972e795 to 3a1b340 Compare June 24, 2026 12:42
@cfkoehler cfkoehler modified the milestones: v8.46.0, v8.47.0 Jun 24, 2026
@rcameronm rcameronm marked this pull request as draft June 25, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rebase Things have happened and now a rebase is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants