Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Allow manual closing of underlying okHttpClient connection pool #289

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,11 @@ public interface BinanceApiRestClient {
* @param listenKey listen key that identifies a data stream
*/
void closeUserDataStream(String listenKey);


/**
* Call to allow the client to shutdown cleanly instead of
* waiting for connection timeouts.
*/
void shutdown();
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public enum RateLimitType {
REQUEST_WEIGHT,
ORDERS
ORDERS,
RAW_REQUESTS
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.binance.api.client.domain.general.Asset;
import com.binance.api.client.domain.general.ExchangeInfo;
import com.binance.api.client.domain.market.*;

import okhttp3.OkHttpClient;
import retrofit2.Call;

import java.util.List;
Expand Down Expand Up @@ -223,4 +225,12 @@ public void keepAliveUserDataStream(String listenKey) {
public void closeUserDataStream(String listenKey) {
executeSync(binanceApiService.closeAliveUserDataStream(listenKey));
}


// Close and remove all idle connections in the pool
@Override
public void shutdown() {
OkHttpClient okHttpClient = BinanceApiServiceGenerator.getSharedClient();
okHttpClient.connectionPool().evictAll();
}
}