Skip to content
Merged
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 @@ -3,7 +3,7 @@

namespace ProGaudi.Tarantool.Client
{
internal interface IResponseWriter : IDisposable
internal interface IRequestWriter : IDisposable
{
void BeginWriting();

Expand Down
12 changes: 6 additions & 6 deletions src/progaudi.tarantool/LogicalConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class LogicalConnection : ILogicalConnection

private readonly IResponseReader _responseReader;

private readonly IResponseWriter _responseWriter;
private readonly IRequestWriter _requestWriter;

private readonly ILog _logWriter;

Expand All @@ -41,7 +41,7 @@ public LogicalConnection(ClientOptions options, RequestIdCounter requestIdCounte

_physicalConnection = new NetworkStreamPhysicalConnection();
_responseReader = new ResponseReader(_clientOptions, _physicalConnection);
_responseWriter = new ResponseWriter(_clientOptions, _physicalConnection);
_requestWriter = new RequestWriter(_clientOptions, _physicalConnection);
}

public uint PingsFailedByTimeoutCount
Expand All @@ -60,7 +60,7 @@ public void Dispose()
_disposed = true;

_responseReader.Dispose();
_responseWriter.Dispose();
_requestWriter.Dispose();
_physicalConnection.Dispose();
}

Expand All @@ -82,7 +82,7 @@ public async Task Connect()
PingsFailedByTimeoutCount = 0;

_responseReader.BeginReading();
_responseWriter.BeginWriting();
_requestWriter.BeginWriting();

_clientOptions.LogWriter?.WriteLine("Server responses reading started.");

Expand All @@ -96,7 +96,7 @@ public bool IsConnected()
return false;
}

return _responseReader.IsConnected && _responseWriter.IsConnected && _physicalConnection.IsConnected;
return _responseReader.IsConnected && _requestWriter.IsConnected && _physicalConnection.IsConnected;
}

private async Task LoginIfNotGuest(GreetingsResponse greetings)
Expand Down Expand Up @@ -141,7 +141,7 @@ private async Task<TResponse> SendRequestImpl<TRequest, TResponse>(TRequest requ
var responseTask = _responseReader.GetResponseTask(requestId);

var headerBuffer = CreateAndSerializeBuffer(request, requestId, bodyBuffer, out var headerLength);
await _responseWriter.Write(
await _requestWriter.Write(
new ArraySegment<byte>(headerBuffer, 0, Constants.PacketSizeBufferSize + (int) headerLength),
new ArraySegment<byte>(bodyBuffer, 0, bodyBuffer.Length));

Expand Down
22 changes: 4 additions & 18 deletions src/progaudi.tarantool/LogicalConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class LogicalConnectionManager : ILogicalConnection

private readonly int _pingCheckInterval = 1000;

private readonly TimeSpan? _pingTimeout = null;
private readonly TimeSpan? _pingTimeout;

private DateTimeOffset _nextPingTime = DateTimeOffset.MinValue;

Expand All @@ -44,16 +44,10 @@ public LogicalConnectionManager(ClientOptions options)
_pingCheckInterval = _clientOptions.ConnectionOptions.PingCheckInterval;
}

this._pingTimeout = this._clientOptions.ConnectionOptions.PingCheckTimeout;
_pingTimeout = _clientOptions.ConnectionOptions.PingCheckTimeout;
}

public uint PingsFailedByTimeoutCount
{
get
{
return _droppableLogicalConnection?.PingsFailedByTimeoutCount ?? 0;
}
}
public uint PingsFailedByTimeoutCount => _droppableLogicalConnection?.PingsFailedByTimeoutCount ?? 0;

public void Dispose()
{
Expand Down Expand Up @@ -135,15 +129,7 @@ private void CheckPing()
}
}

public bool IsConnected()
{
if (!_connected.WaitOne(_connectionTimeout))
{
return false;
}

return IsConnectedInternal();
}
public bool IsConnected() => _connected.WaitOne(_connectionTimeout) && IsConnectedInternal();

private bool IsConnectedInternal()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace ProGaudi.Tarantool.Client
{
internal class ResponseWriter : IResponseWriter
internal class RequestWriter : IRequestWriter
{
private readonly ClientOptions _clientOptions;
private readonly IPhysicalConnection _physicalConnection;
Expand All @@ -17,7 +17,7 @@ internal class ResponseWriter : IResponseWriter
private readonly ManualResetEventSlim _newRequestsAvailable;
private bool _disposed;

public ResponseWriter(ClientOptions clientOptions, IPhysicalConnection physicalConnection)
public RequestWriter(ClientOptions clientOptions, IPhysicalConnection physicalConnection)
{
_clientOptions = clientOptions;
_physicalConnection = physicalConnection;
Expand Down
19 changes: 0 additions & 19 deletions src/progaudi.tarantool/Utils/AsyncLazy.cs

This file was deleted.