Further Thrift service optimization
As noted in comments in #2620, it may be possible to:
- Modify ThriftProcessorTypes and/or ThriftClientTypes to be enum types
- It may be possible to have an enum of service names (or use the name from the enum in 1 above) rather than using the Thrift IDL service name in the
TMultiplexedProcessor.registerProcessorcall.
It looks like TMultiplexedProcessor and TMultiplexedProtocol require a String for the serviceName so I'm not sure that an enum would work in its place.
Is the goal to reduce the size of serviceName? If so, could it be as simple as replacing the serviceName String with something shorter where the types are created in ThriftClientTypes?
So these are two different things. (1) was to modify ThriftClientTypes to be an enum object as a whole. This may be OBE at this point based on the current definition (I can't remember). (2) was to create a different enum to use in ThriftClientTypes and ThriftProcessorTypes to reduce the size of the service name as the String is sent over the wire and the values in the client and server have to match.
Edit: Looking again at ThriftClientTypes, it's not as complicated as I remember. It should be relatively straight forward to make it an enum type.
Modify ThriftProcessorTypes and/or ThriftClientTypes to be enum types
I'm not sure that this is possible as Java enum types cannot use generics, which directly impacts the users of this class to know exactly which type of Thrift client is being returned.
Reading the related comments in #2620 it was also suggested that the serviceNames could be shorter Strings instead enums. It looks like we could potentially do something like this by defining constants in ThriftClientTypes and using those constants in place of the serviceNames to reduce the size of the String sent over the wire:
final static String CLIENT_SERVICE = "cl";
final static String COMPACTOR_SERVICE = "cm";
...
public static final ThriftClientType<ClientService.Client,ClientService.Client.Factory> CLIENT =
new ThriftClientType<>(CLIENT_SERVICE, new ClientService.Client.Factory());
public static final ThriftClientType<CompactorService.Client,
CompactorService.Client.Factory> COMPACTOR =
new ThriftClientType<>(COMPACTOR_SERVICE, new CompactorService.Client.Factory());
That was the idea behind the enum. It would end up being a shorter value than the Thrift service name.