Skip to content
Closed
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
4 changes: 2 additions & 2 deletions src/Databento.Client/DataSources/Caching/DiskRecordCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public async IAsyncEnumerable<Record> ReadAsync([EnumeratorCancellation] Cancell
using var reader = new DbnFileReader(_cacheFilePath);
long index = 0;

await foreach (var record in reader.ReadRecordsAsync(cancellationToken))
await foreach (var record in reader.ReadRecordsAsync(cancellationToken).ConfigureAwait(false))
{
index++;
yield return record;
Expand All @@ -140,7 +140,7 @@ public async IAsyncEnumerable<Record> ReadFromIndexAsync(long startIndex, [Enume
using var reader = new DbnFileReader(_cacheFilePath);
long index = 0;

await foreach (var record in reader.ReadRecordsAsync(cancellationToken))
await foreach (var record in reader.ReadRecordsAsync(cancellationToken).ConfigureAwait(false))
{
if (index >= startIndex)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Databento.Client/DataSources/Caching/MemoryRecordCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public async IAsyncEnumerable<Record> ReadAsync([EnumeratorCancellation] Cancell
yield return record;
}

await Task.CompletedTask; // Keep async signature
await Task.CompletedTask.ConfigureAwait(false); // Keep async signature
}

/// <inheritdoc/>
Expand All @@ -100,7 +100,7 @@ public async IAsyncEnumerable<Record> ReadFromIndexAsync(long startIndex, [Enume
yield return snapshot[i];
}

await Task.CompletedTask; // Keep async signature
await Task.CompletedTask.ConfigureAwait(false); // Keep async signature
}

/// <inheritdoc/>
Expand Down
4 changes: 2 additions & 2 deletions src/Databento.Client/DataSources/FileDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public async IAsyncEnumerable<Record> StreamAsync([EnumeratorCancellation] Cance
long index = 0;
long? previousNanos = null;

await foreach (var record in _reader.ReadRecordsAsync(linkedCts.Token))
await foreach (var record in _reader.ReadRecordsAsync(linkedCts.Token).ConfigureAwait(false))
{
// Check for pause/stop
if (!await Playback.WaitIfPausedAsync(linkedCts.Token).ConfigureAwait(false))
Expand Down Expand Up @@ -235,6 +235,6 @@ public async ValueTask DisposeAsync()
_reader?.Dispose();

Interlocked.Exchange(ref _disposeState, 2);
await Task.CompletedTask;
await Task.CompletedTask.ConfigureAwait(false);
}
}
2 changes: 1 addition & 1 deletion src/Databento.Client/DataSources/HistoricalDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public async IAsyncEnumerable<Record> StreamAsync([EnumeratorCancellation] Cance
subscription.Symbols,
_startTime,
_endTime,
linkedCts.Token))
linkedCts.Token).ConfigureAwait(false))
{
// Check for pause/stop
if (!await Playback.WaitIfPausedAsync(linkedCts.Token).ConfigureAwait(false))
Expand Down
2 changes: 1 addition & 1 deletion src/Databento.Client/DataSources/LiveDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public async IAsyncEnumerable<Record> StreamAsync([EnumeratorCancellation] Cance
if (_recordChannel == null)
throw new InvalidOperationException("Not connected. Call ConnectAsync() first.");

await foreach (var record in _recordChannel.Reader.ReadAllAsync(cancellationToken))
await foreach (var record in _recordChannel.Reader.ReadAllAsync(cancellationToken).ConfigureAwait(false))
{
yield return record;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Databento.Client/Historical/HistoricalClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public async IAsyncEnumerable<Record> GetRangeAsync(
}, cancellationToken);

// Stream results
await foreach (var record in channel.Reader.ReadAllAsync(cancellationToken))
await foreach (var record in channel.Reader.ReadAllAsync(cancellationToken).ConfigureAwait(false))
{
yield return record;
}
Expand Down Expand Up @@ -427,7 +427,7 @@ public async IAsyncEnumerable<Record> GetRangeAsync(
}, cancellationToken);

// Stream results
await foreach (var record in channel.Reader.ReadAllAsync(cancellationToken))
await foreach (var record in channel.Reader.ReadAllAsync(cancellationToken).ConfigureAwait(false))
{
yield return record;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Databento.Client/Live/BacktestingClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public async IAsyncEnumerable<Record> StreamAsync([EnumeratorCancellation] Cance

Interlocked.Exchange(ref _connectionState, (int)ConnectionState.Streaming);

await foreach (var record in _dataSource.StreamAsync(cancellationToken))
await foreach (var record in _dataSource.StreamAsync(cancellationToken).ConfigureAwait(false))
{
// Fire event
DataReceived?.Invoke(this, new DataReceivedEventArgs(record));
Expand Down
6 changes: 3 additions & 3 deletions src/Databento.Client/Live/LiveClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ internal LiveClient(
_healthMonitor = new ConnectionHealthMonitor(
_resilienceOptions,
_logger,
async ct => await PerformReconnectAsync(ct));
PerformReconnectAsync);
}
// MEDIUM FIX: Use Interlocked for consistency
Interlocked.Exchange(ref _connectionState, (int)ConnectionState.Disconnected);
Expand Down Expand Up @@ -584,7 +584,7 @@ public async Task ResubscribeAsync(CancellationToken cancellationToken = default
throw DbentoException.CreateFromErrorCode($"Resubscription failed: {error}", result);
}

await Task.CompletedTask;
await Task.CompletedTask.ConfigureAwait(false);
}

/// <summary>
Expand Down Expand Up @@ -616,7 +616,7 @@ private async Task PerformReconnectAsync(CancellationToken cancellationToken)
public async IAsyncEnumerable<Record> StreamAsync(
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
await foreach (var record in _recordChannel.Reader.ReadAllAsync(cancellationToken))
await foreach (var record in _recordChannel.Reader.ReadAllAsync(cancellationToken).ConfigureAwait(false))
{
yield return record;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Databento.Client/Reference/AdjustmentFactorsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ public async Task<List<AdjustmentFactorRecord>> GetRangeAsync(
var url = $"{_baseUrl}/v0/adjustment_factors.get_range";
_logger.LogDebug("POST {Url}", url);

// MEDIUM FIX: Execute with retry policy for transient failures
var content = new FormUrlEncodedContent(queryParams);
// MEDIUM FIX: Execute with retry policy for transient failures
var response = await _retryPolicy.ExecuteAsync(async () =>
{
return await _httpClient.PostAsync(url, content, cancellationToken);
});
var content = new FormUrlEncodedContent(queryParams);
return await _httpClient.PostAsync(url, content, cancellationToken).ConfigureAwait(false);
}).ConfigureAwait(false);
await ReferenceApiHelpers.EnsureSuccessStatusCode(response).ConfigureAwait(false);

// Parse JSONL response (Databento Reference API returns JSON Lines format)
Expand Down
8 changes: 4 additions & 4 deletions src/Databento.Client/Reference/CorporateActionsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ public async Task<List<CorporateActionRecord>> GetRangeAsync(
var url = $"{_baseUrl}/v0/corporate_actions.get_range";
_logger.LogDebug("POST {Url}", url);

// MEDIUM FIX: Execute with retry policy for transient failures
var content = new FormUrlEncodedContent(queryParams);
// MEDIUM FIX: Execute with retry policy for transient failures
var response = await _retryPolicy.ExecuteAsync(async () =>
{
return await _httpClient.PostAsync(url, content, cancellationToken);
});
var content = new FormUrlEncodedContent(queryParams);
return await _httpClient.PostAsync(url, content, cancellationToken).ConfigureAwait(false);
}).ConfigureAwait(false);
await ReferenceApiHelpers.EnsureSuccessStatusCode(response).ConfigureAwait(false);

// Parse JSONL response (Databento Reference API returns JSON Lines format)
Expand Down
2 changes: 1 addition & 1 deletion src/Databento.Client/Reference/ReferenceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ public async ValueTask DisposeAsync()
_httpClient?.Dispose();
_disposed = true;

await Task.CompletedTask;
await Task.CompletedTask.ConfigureAwait(false);
}
}
16 changes: 8 additions & 8 deletions src/Databento.Client/Reference/SecurityMasterApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ public async Task<List<SecurityMasterRecord>> GetLastAsync(

try
{
// MEDIUM FIX: Execute with retry policy for transient failures
var content = new FormUrlEncodedContent(queryParams);
// MEDIUM FIX: Execute with retry policy for transient failures
var response = await _retryPolicy.ExecuteAsync(async () =>
{
return await _httpClient.PostAsync(url, content, cancellationToken);
});
var content = new FormUrlEncodedContent(queryParams);
return await _httpClient.PostAsync(url, content, cancellationToken).ConfigureAwait(false);
}).ConfigureAwait(false);
await ReferenceApiHelpers.EnsureSuccessStatusCode(response).ConfigureAwait(false);

// Parse JSONL response (Databento Reference API returns JSON Lines format)
Expand Down Expand Up @@ -174,12 +174,12 @@ public async Task<List<SecurityMasterRecord>> GetRangeAsync(
var url = $"{_baseUrl}/v0/security_master.get_range";
_logger.LogDebug("POST {Url}", url);

// MEDIUM FIX: Execute with retry policy for transient failures
var content = new FormUrlEncodedContent(queryParams);
// MEDIUM FIX: Execute with retry policy for transient failures
var response = await _retryPolicy.ExecuteAsync(async () =>
{
return await _httpClient.PostAsync(url, content, cancellationToken);
});
var content = new FormUrlEncodedContent(queryParams);
return await _httpClient.PostAsync(url, content, cancellationToken).ConfigureAwait(false);
}).ConfigureAwait(false);
await ReferenceApiHelpers.EnsureSuccessStatusCode(response).ConfigureAwait(false);

// Parse JSONL response (Databento Reference API returns JSON Lines format)
Expand Down
8 changes: 4 additions & 4 deletions src/Databento.Client/Resilience/ConnectionHealthMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private async Task MonitorLoopAsync()
{
try
{
await Task.Delay(checkInterval, _cts.Token);
await Task.Delay(checkInterval, _cts.Token).ConfigureAwait(false);

var timeSinceActivity = DateTime.UtcNow - _lastActivityTime;

Expand All @@ -136,7 +136,7 @@ private async Task MonitorLoopAsync()
if (_options.AutoReconnect)
{
await TryReconnectAsync(
new TimeoutException($"No activity for {timeSinceActivity.TotalSeconds:F1} seconds"));
new TimeoutException($"No activity for {timeSinceActivity.TotalSeconds:F1} seconds")).ConfigureAwait(false);
}
}
}
Expand Down Expand Up @@ -189,11 +189,11 @@ private async Task TryReconnectAsync(Exception triggerException)
"Reconnection attempt {Attempt}/{Max} in {Delay:F1}s",
attempt + 1, _options.RetryPolicy.MaxRetries, delay.TotalSeconds);

await Task.Delay(delay, _cts.Token);
await Task.Delay(delay, _cts.Token).ConfigureAwait(false);

try
{
await _reconnectAction(_cts.Token);
await _reconnectAction(_cts.Token).ConfigureAwait(false);

// Success!
ReconnectionCount++;
Expand Down