Skip to content

Commit

Permalink
Tidy EdgeDBConnection class. (#89)
Browse files Browse the repository at this point in the history
- Add `TLSServerName` and support for it in the clients
- Ensure consistent ordering and naming of properties and backing fields.
- Fix parsing of TLS security mode
- Remove some checks in property setters, they will be re-added later.
  • Loading branch information
dnwpark authored Jan 29, 2025
1 parent ee5ff0e commit 33388b8
Show file tree
Hide file tree
Showing 7 changed files with 240 additions and 102 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(connection.Timeout);
ConnectionTimeout = TimeSpan.FromMilliseconds(connection.WaitUntilAvailable);
_stateDescriptorId = CodecBuilder.InvalidCodec;
ClientConfig = clientConfig;
_semaphore = new SemaphoreSlim(1, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/EdgeDB.Net.Driver/Clients/EdgeDBTcpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ or SocketError.HostNotFound
{
AllowRenegotiation = true,
ApplicationProtocols = new List<SslApplicationProtocol> {new("edgedb-binary")},
TargetHost = Connection.Hostname,
TargetHost = Connection.TLSServerName ?? Connection.Hostname,
EnabledSslProtocols = SslProtocols.None,
CertificateRevocationCheckMode = X509RevocationMode.NoCheck
};
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)_connection.Timeout)
}, (int)_connection.WaitUntilAvailable)
? result!
: throw new TimeoutException($"Couldn't find a client after {_connection.Timeout}ms");
: throw new TimeoutException($"Couldn't find a client after {_connection.WaitUntilAvailable}ms");

client.AcceptHolder(await _poolHolder.GetPoolHandleAsync(token).ConfigureAwait(false));
return client.WithSession(_session);
Expand Down
Loading

0 comments on commit 33388b8

Please sign in to comment.