use of com.linkedin.common.callback.SuccessCallback in project rest.li by linkedin.
the class DynamicClient method getClientCallback.
private Callback<TransportClient> getClientCallback(Request request, RequestContext requestContext, final boolean restOverStream, Callback<? extends Response> callback, SuccessCallback<Client> clientSuccessCallback) {
return new Callback<TransportClient>() {
@Override
public void onError(Throwable e) {
TimingContextUtil.markTiming(requestContext, TIMING_KEY);
callback.onError(e);
warn(_log, "unable to find service for: ", extractLogInfo(request));
}
@Override
public void onSuccess(TransportClient client) {
TimingContextUtil.markTiming(requestContext, TIMING_KEY);
if (client != null) {
clientSuccessCallback.onSuccess(new TransportClientAdapter(client, restOverStream));
} else {
callback.onError(new ServiceUnavailableException("PEGA_1000. Unknown: " + request.getURI(), "got null client from load balancer"));
}
}
};
}
Aggregations