1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-16 10:53:08 +00:00

added ability to set optional http client for preventing connection pool exhaustion https://stackoverflow.com/a/48778707/4993930

This commit is contained in:
Artem Kurianov
2020-08-18 09:39:14 +00:00
parent 3e3bf5329a
commit 387ef0d1a6
5 changed files with 222 additions and 47 deletions
+16 -3
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using CryptoExchange.Net.Authentication;
using CryptoExchange.Net.Interfaces;
using CryptoExchange.Net.Logging;
@@ -126,7 +127,10 @@ namespace CryptoExchange.Net.Objects
/// The time the server has to respond to a request before timing out
/// </summary>
public TimeSpan RequestTimeout { get; set; } = TimeSpan.FromSeconds(30);
/// <summary>
/// http client
/// </summary>
public HttpClient? HttpClient;
/// <summary>
/// ctor
/// </summary>
@@ -134,7 +138,15 @@ namespace CryptoExchange.Net.Objects
public RestClientOptions(string baseAddress): base(baseAddress)
{
}
/// <summary>
/// ctor
/// </summary>
/// <param name="baseAddress"></param>
/// <param name="httpClient">Shared http client</param>
public RestClientOptions(HttpClient httpClient, string baseAddress) : base(baseAddress)
{
HttpClient = httpClient;
}
/// <summary>
/// Create a copy of the options
/// </summary>
@@ -150,7 +162,8 @@ namespace CryptoExchange.Net.Objects
LogWriters = LogWriters,
RateLimiters = RateLimiters,
RateLimitingBehaviour = RateLimitingBehaviour,
RequestTimeout = RequestTimeout
RequestTimeout = RequestTimeout,
HttpClient = HttpClient
};
if (ApiCredentials != null)