in grpc-gcp/src/main/java/com/google/cloud/grpc/GcpClientCall.java [105:136]
public void sendMessage(ReqT message) {
synchronized (this) {
if (!started) {
startNanos = System.nanoTime();
// Check if the current channelRef is bound with the key and change it if necessary.
// If no channel is bound with the key, use the least busy one.
keys = delegateChannel.checkKeys(message, true, methodDescriptor);
String key = null;
if (keys != null
&& keys.size() == 1
&& delegateChannel.getChannelRef(keys.get(0)) != null) {
key = keys.get(0);
}
if (affinity != null && affinity.getCommand().equals(AffinityConfig.Command.BIND)) {
delegateChannelRef = delegateChannel.getChannelRefForBind();
} else {
delegateChannelRef = delegateChannel.getChannelRef(key);
}
delegateChannelRef.activeStreamsCountIncr();
// Create the client call and do the previous operations.
delegateCall = delegateChannelRef.getChannel().newCall(methodDescriptor, callOptions);
for (Runnable call : calls) {
call.run();
}
calls.clear();
started = true;
}
}
delegateCall.sendMessage(message);
}