-
Notifications
You must be signed in to change notification settings - Fork 31
Description
I have a need to supply a threadPoolSize
to the OncRpcSvcBuilder's withSelectorThreadPoolSize
method for generated clients.
Is there already a way? If not, I'm happy to provide a PR. I see that in the past that's been done by adding additional constructors to OncRpcClient.java
. Maybe the most recent time was for PR 53?
Before I give you a PR, I wanted to ask, would it be useful to have a OncRpcClient
constructor that takes an instance of OncRpcSvcBuilder
so that we wouldn't need additional constructors every time we wanted to pass in a parameter that isn't already exposed? For example, I only need to limit the size of the selectorThreadPool
but maybe someone else would need to limit the size of the workerThreadPool
next month and would need to go through this process again. If one of the constructors took a OncRpcSvcBuilder
then it could also make sure that everything that is needed for a client is set, like .withClientMode()
and .withPort(localPort)
, but otherwise allow the end user to construct the client service with everything else allowed by the builder.
I'm thinking in my PR I'd leave all of the existing constructors alone (so it would be backward compatible with existing code) but change the one that all of the other's call, making it look like this:
public OncRpcClient(InetSocketAddress socketAddress, int protocol, int localPort, IoStrategy ioStrategy, String serviceName) {
this(socketAddress, localPort, new OncRpcSvcBuilder()
.withIpProtocolType(protocol)
.withIoStrategy(ioStrategy)
.withServiceName(serviceName));
}
and then I'd add this one (called by the one above, but could also be used directly by end users who need it like me):
public OncRpcClient(InetSocketAddress socketAddress, int localPort, OncRpcSvcBuilder builder) {
_socketAddress = socketAddress;
_rpcsvc = (builder == null ? new OncRpcSvcBuilder() : builder)
.withClientMode()
.withPort(localPort)
.build();
}
I wanted to vet that idea with you before I do the work of committing a PR. It seems like it would prevent additional future churn just to expose additional things that the builder already provides.
Thanks for your help and input.