1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-07-25 18:57:07 +00:00
This commit is contained in:
Artem Kurianov 2020-08-17 08:44:30 +00:00
parent 9b8950747f
commit fb61b6931b
7 changed files with 3089 additions and 3127 deletions

View File

@ -633,13 +633,12 @@
<param name="uri"></param>
<returns></returns>
</member>
<member name="M:CryptoExchange.Net.Interfaces.IRequestFactory.Configure(System.TimeSpan,CryptoExchange.Net.Objects.ApiProxy,System.Boolean)">
<member name="M:CryptoExchange.Net.Interfaces.IRequestFactory.Configure(System.TimeSpan,CryptoExchange.Net.Objects.ApiProxy)">
<summary>
Configure the requests created by this factory
</summary>
<param name="requestTimeout">Request timeout to use</param>
<param name="proxy">Proxy settings to use</param>
<param name="isTracingEnabled">Should generate unique id for requests</param>
</member>
<member name="T:CryptoExchange.Net.Interfaces.IResponse">
<summary>
@ -2031,13 +2030,12 @@
Request object
</summary>
</member>
<member name="M:CryptoExchange.Net.Requests.Request.#ctor(System.Net.Http.HttpRequestMessage,System.Net.Http.HttpClient,System.Boolean)">
<member name="M:CryptoExchange.Net.Requests.Request.#ctor(System.Net.Http.HttpRequestMessage,System.Net.Http.HttpClient)">
<summary>
Create request object for web request
</summary>
<param name="request"></param>
<param name="client"></param>
<param name="isTracingEnabled">if true, should assign unique id for request</param>
</member>
<member name="P:CryptoExchange.Net.Requests.Request.Content">
<inheritdoc />
@ -2071,7 +2069,7 @@
WebRequest factory
</summary>
</member>
<member name="M:CryptoExchange.Net.Requests.RequestFactory.Configure(System.TimeSpan,CryptoExchange.Net.Objects.ApiProxy,System.Boolean)">
<member name="M:CryptoExchange.Net.Requests.RequestFactory.Configure(System.TimeSpan,CryptoExchange.Net.Objects.ApiProxy)">
<inheritdoc />
</member>
<member name="M:CryptoExchange.Net.Requests.RequestFactory.Create(System.Net.Http.HttpMethod,System.String)">
@ -2959,39 +2957,9 @@
<member name="M:CryptoExchange.Net.Sockets.WebsocketFactory.CreateWebsocket(CryptoExchange.Net.Logging.Log,System.String,System.Collections.Generic.IDictionary{System.String,System.String},System.Collections.Generic.IDictionary{System.String,System.String})">
<inheritdoc />
</member>
<member name="T:System.Diagnostics.CodeAnalysis.AllowNullAttribute">
<summary>
Specifies that <see langword="null"/> is allowed as an input even if the
corresponding type disallows it.
</summary>
</member>
<member name="M:System.Diagnostics.CodeAnalysis.AllowNullAttribute.#ctor">
<summary>
Initializes a new instance of the <see cref="T:System.Diagnostics.CodeAnalysis.AllowNullAttribute"/> class.
</summary>
</member>
<member name="T:System.Diagnostics.CodeAnalysis.DisallowNullAttribute">
<summary>
Specifies that <see langword="null"/> is disallowed as an input even if the
corresponding type allows it.
</summary>
</member>
<member name="M:System.Diagnostics.CodeAnalysis.DisallowNullAttribute.#ctor">
<summary>
Initializes a new instance of the <see cref="T:System.Diagnostics.CodeAnalysis.DisallowNullAttribute"/> class.
</summary>
</member>
<member name="T:System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute">
<summary>
Specifies that a method that will never return under any circumstance.
</summary>
</member>
<member name="M:System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute.#ctor">
<summary>
Initializes a new instance of the <see cref="T:System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute"/> class.
</summary>
</member>
<member name="T:System.Diagnostics.CodeAnalysis.DoesNotReturnIfAttribute">
</members>
</doc>
ember name="T:System.Diagnostics.CodeAnalysis.DoesNotReturnIfAttribute">
<summary>
Specifies that the method will not return if the associated <see cref="T:System.Boolean"/>
parameter is passed the specified value.

View File

@ -29,7 +29,7 @@ namespace CryptoExchange.Net.Interfaces
/// <summary>
/// internal request id for tracing
/// </summary>
string? RequestId { get; }
string RequestId { get; }
/// <summary>
/// Set byte content
/// </summary>

View File

@ -22,7 +22,6 @@ namespace CryptoExchange.Net.Interfaces
/// </summary>
/// <param name="requestTimeout">Request timeout to use</param>
/// <param name="proxy">Proxy settings to use</param>
/// <param name="isTracingEnabled">Should generate unique id for requests</param>
void Configure(TimeSpan requestTimeout, ApiProxy? proxy, bool isTracingEnabled=false);
void Configure(TimeSpan requestTimeout, ApiProxy? proxy);
}
}

View File

@ -127,7 +127,7 @@ 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);
public bool IsRequestsTracingEnabled { get; set; } = false;
/// <summary>
/// ctor
/// </summary>

View File

@ -22,16 +22,12 @@ namespace CryptoExchange.Net.Requests
/// </summary>
/// <param name="request"></param>
/// <param name="client"></param>
/// <param name="isTracingEnabled">if true, should assign unique id for request</param>
public Request(HttpRequestMessage request, HttpClient client, bool isTracingEnabled=false)
public Request(HttpRequestMessage request, HttpClient client)
{
httpClient = client;
this.request = request;
if (isTracingEnabled)
{
RequestId = Path.GetRandomFileName();
}
}
/// <inheritdoc />
public string? Content { get; private set; }
@ -52,7 +48,7 @@ namespace CryptoExchange.Net.Requests
/// <inheritdoc />
public Uri Uri => request.RequestUri;
/// <inheritdoc />
public string? RequestId { get; }
public string RequestId { get; }
/// <inheritdoc />
public void SetContent(string data, string contentType)

View File

@ -14,9 +14,8 @@ namespace CryptoExchange.Net.Requests
private HttpClient? httpClient;
private bool isTracingEnabled;
/// <inheritdoc />
public void Configure(TimeSpan requestTimeout, ApiProxy? proxy, bool isTracingEnabled = false)
public void Configure(TimeSpan requestTimeout, ApiProxy? proxy)
{
this.isTracingEnabled = isTracingEnabled;
HttpMessageHandler handler = new HttpClientHandler()
{
Proxy = proxy == null ? null : new WebProxy
@ -35,7 +34,7 @@ namespace CryptoExchange.Net.Requests
if (httpClient == null)
throw new InvalidOperationException("Cant create request before configuring http client");
return new Request(new HttpRequestMessage(method, uri), httpClient, isTracingEnabled);
return new Request(new HttpRequestMessage(method, uri), httpClient);
}
}
}

View File

@ -83,7 +83,7 @@ namespace CryptoExchange.Net
throw new ArgumentNullException(nameof(exchangeOptions));
RequestTimeout = exchangeOptions.RequestTimeout;
RequestFactory.Configure(exchangeOptions.RequestTimeout, exchangeOptions.Proxy,exchangeOptions.IsRequestsTracingEnabled);
RequestFactory.Configure(exchangeOptions.RequestTimeout, exchangeOptions.Proxy);
RateLimitBehaviour = exchangeOptions.RateLimitingBehaviour;
var rateLimiters = new List<IRateLimiter>();
foreach (var rateLimiter in exchangeOptions.RateLimiters)
@ -197,7 +197,7 @@ namespace CryptoExchange.Net
if (method == HttpMethod.Post)
paramString = " with request body " + request.Content;
log.Write(LogVerbosity.Debug, $"Sending {method}{(signed ? " signed" : "")} request to {request.Uri}{paramString ?? " "}{(apiProxy == null? "": $" via proxy {apiProxy.Host}")} {(request.RequestId==null?"":$" with id {request.RequestId}")}");
log.Write(LogVerbosity.Debug, $"Sending {method}{(signed ? " signed" : "")} request to {request.Uri}{paramString ?? " "}{(apiProxy == null? "": $" via proxy {apiProxy.Host}")} with id {request.RequestId}");
return await GetResponse<T>(request, cancellationToken).ConfigureAwait(false);
}
@ -224,7 +224,7 @@ namespace CryptoExchange.Net
var data = await reader.ReadToEndAsync().ConfigureAwait(false);
responseStream.Close();
response.Close();
log.Write(LogVerbosity.Debug, $"Data {(request.RequestId==null?"":$"for request {request.RequestId} ")}received: {data}");
log.Write(LogVerbosity.Debug, $"Data for request {request.RequestId} received: {data}");
var parseResult = ValidateJson(data);
if (!parseResult.Success)
@ -249,7 +249,7 @@ namespace CryptoExchange.Net
{
using var reader = new StreamReader(responseStream);
var data = await reader.ReadToEndAsync().ConfigureAwait(false);
log.Write(LogVerbosity.Debug, $"Error {(request.RequestId == null ? "" : $"for request {request.RequestId} ")}received: {data}");
log.Write(LogVerbosity.Debug, $"Error for request {request.RequestId} received: {data}");
responseStream.Close();
response.Close();
var parseResult = ValidateJson(data);