in folsom/src/main/java/com/spotify/folsom/client/DefaultRawMemcacheClient.java [235:264]
public <T> CompletionStage<T> send(final Request<T> request) {
if (request instanceof SetRequest) {
SetRequest setRequest = (SetRequest) request;
byte[] value = setRequest.getValue();
if (value.length > maxSetLength) {
return (CompletionStage<T>)
onExecutor(CompletableFuture.completedFuture(MemcacheStatus.VALUE_TOO_LARGE));
}
}
if (!tryIncrementPending()) {
// Do the disconnect check in here instead of outside
// to get better performance in the happy case.
String disconnectReason = this.disconnectReason.get();
if (disconnectReason != null) {
MemcacheClosedException exception =
new MemcacheClosedException(
String.format("%s, memcached=%s", disconnectReason, address.getHostText()));
return onExecutor(CompletableFutures.exceptionallyCompletedFuture(exception));
}
return onExecutor(
CompletableFutures.exceptionallyCompletedFuture(
new MemcacheOverloadedException("too many outstanding requests")));
}
channel.write(request, new RequestWritePromise(channel, request));
flusher.flush();
return onExecutor(request.asFuture());
}