Skip to content

Commit

Permalink
Move Timeout to Connection. (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnwpark authored Jan 21, 2025
2 parents aae1949 + a3a75ce commit 7fba716
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/EdgeDB.Net.Driver/Clients/EdgeDBBinaryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public EdgeDBBinaryClient(
Connection = connection;
ServerKey = new byte[32];
MessageTimeout = TimeSpan.FromMilliseconds(clientConfig.MessageTimeout);
ConnectionTimeout = TimeSpan.FromMilliseconds(clientConfig.ConnectionTimeout);
ConnectionTimeout = TimeSpan.FromMilliseconds(connection.Timeout);
_stateDescriptorId = CodecBuilder.InvalidCodec;
ClientConfig = clientConfig;
_semaphore = new SemaphoreSlim(1, 1);
Expand Down
4 changes: 2 additions & 2 deletions src/EdgeDB.Net.Driver/EdgeDBClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@ internal async Task<BaseEdgeDBClient> GetOrCreateClientAsync(CancellationToken t
{
token.ThrowIfCancellationRequested();
return _availableClients.TryPop(out result);
}, (int)_poolConfig.ConnectionTimeout)
}, (int)_connection.Timeout)
? result!
: throw new TimeoutException($"Couldn't find a client after {_poolConfig.ConnectionTimeout}ms");
: throw new TimeoutException($"Couldn't find a client after {_connection.Timeout}ms");

client.AcceptHolder(await _poolHolder.GetPoolHandleAsync(token).ConfigureAwait(false));
return client.WithSession(_session);
Expand Down
6 changes: 0 additions & 6 deletions src/EdgeDB.Net.Driver/EdgeDBConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,6 @@ public class EdgeDBConfig
/// </summary>
public uint MaxConnectionRetries { get; set; } = 5;

/// <summary>
/// Gets or sets the number of miliseconds a client will wait for a connection to be
/// established with the server.
/// </summary>
public uint ConnectionTimeout { get; set; } = 5000;

/// <summary>
/// Gets or sets the max amount of miliseconds a client will wait for an expected message.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions src/EdgeDB.Net.Driver/EdgeDBConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ public TLSSecurityMode TLSSecurity
set => _tlsSecurity = value;
}

/// <summary>
/// Gets or sets the number of miliseconds a client will wait for a connection to be
/// established with the server.
/// </summary>
[JsonProperty("wait_until_available")]
public uint Timeout { get; set; } = 30000;

/// <summary>
/// Gets or sets the secret key used to authenticate with cloud instances.
/// </summary>
Expand Down

0 comments on commit 7fba716

Please sign in to comment.