Improve per on price update
This commit is contained in:
@@ -8,4 +8,5 @@ public interface IInfluxDbRepository
|
||||
|
||||
Task<T> QueryAsync<T>(Func<QueryApi, Task<T>> action);
|
||||
void Write(Action<WriteApi> action);
|
||||
Task WriteAsync(Func<WriteApi, Task> action);
|
||||
}
|
||||
@@ -111,9 +111,9 @@ public class CandleRepository : ICandleRepository
|
||||
return results;
|
||||
}
|
||||
|
||||
public void InsertCandle(Candle candle)
|
||||
public async Task InsertCandle(Candle candle)
|
||||
{
|
||||
_influxDbRepository.Write(write =>
|
||||
await _influxDbRepository.WriteAsync(write =>
|
||||
{
|
||||
PriceDto price = PriceHelpers.Map(candle);
|
||||
write.WriteMeasurement(
|
||||
@@ -121,6 +121,7 @@ public class CandleRepository : ICandleRepository
|
||||
WritePrecision.Ns,
|
||||
_priceBucket,
|
||||
_influxDbRepository.Organization);
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,13 @@ public class InfluxDbRepository : IInfluxDbRepository
|
||||
action(write);
|
||||
}
|
||||
|
||||
public Task WriteAsync(Func<WriteApi, Task> action)
|
||||
{
|
||||
// Get write API asynchronously
|
||||
using var client = new InfluxDBClient(_url, _token);
|
||||
using var write = client.GetWriteApi();
|
||||
return action(write);
|
||||
}
|
||||
public async Task<T> QueryAsync<T>(Func<QueryApi, Task<T>> action)
|
||||
{
|
||||
using var client = InfluxDBClientFactory.Create(_url, _token);
|
||||
|
||||
Reference in New Issue
Block a user