use of mockwebserver3.Dispatcher in project hmftools by hartwigmedical.
the class SlicerHttpClient method create.
@NotNull
static OkHttpClient create(final int maxRequests) {
final Dispatcher requestDispatcher = new Dispatcher();
requestDispatcher.setMaxRequests(maxRequests);
requestDispatcher.setMaxRequestsPerHost(maxRequests);
return new OkHttpClient.Builder().connectionPool(new ConnectionPool(20, 1, TimeUnit.MINUTES)).readTimeout(20, TimeUnit.SECONDS).connectTimeout(20, TimeUnit.SECONDS).writeTimeout(20, TimeUnit.SECONDS).dispatcher(requestDispatcher).build();
}
use of mockwebserver3.Dispatcher in project KalturaGeneratedAPIClientsJava by kaltura.
the class APIOkRequestsExecutor method cancelRequest.
@Override
public void cancelRequest(String reqId) {
Dispatcher dispatcher = getOkClient(null).dispatcher();
Call call = findCall(reqId, dispatcher.queuedCalls());
if (call != null) {
call.cancel();
}
call = findCall(reqId, dispatcher.runningCalls());
if (call != null) {
call.cancel();
}
}
use of mockwebserver3.Dispatcher in project KalturaGeneratedAPIClientsJava by kaltura.
the class APIOkRequestsExecutor method hasRequest.
// TODO: cancel check on executor + null check on provider
// @Override
public boolean hasRequest(String reqId) {
Dispatcher dispatcher = getOkClient(null).dispatcher();
Call call = findCall(reqId, dispatcher.queuedCalls());
if (call != null) {
return true;
}
call = findCall(reqId, dispatcher.runningCalls());
return call != null;
}
use of mockwebserver3.Dispatcher in project crnk-framework by crnk-project.
the class OkHttpBraveIntegration method onBuild.
@Override
public void onBuild(OkHttpClient.Builder builder) {
Interceptor interceptor = TracingInterceptor.create(httpTracing);
builder.addNetworkInterceptor(interceptor);
builder.dispatcher(new Dispatcher(httpTracing.tracing().currentTraceContext().executorService(new Dispatcher().executorService())));
}
use of mockwebserver3.Dispatcher in project butter-android by butterproject.
the class BaseProvider method cancel.
/**
* This method will be called when user is done with data that he required. Provider should at this point
* clean after itself. For example cancel all ongoing network request.
*/
@CallSuper
public void cancel() {
final Dispatcher dispatcher = client.dispatcher();
dispatcher.executorService().execute(new Runnable() {
@Override
public void run() {
if (dispatcher.queuedCallsCount() > 0) {
for (Call call : dispatcher.queuedCalls()) {
if (getClass().equals(call.request().tag())) {
call.cancel();
}
}
}
if (dispatcher.runningCallsCount() > 0) {
for (Call call : dispatcher.runningCalls()) {
if (getClass().equals(call.request().tag())) {
call.cancel();
}
}
}
}
});
}
Aggregations