Skip to content

Commit 604a9ed

Browse files
committed
bug fix to indicate partial failures
1 parent 01489af commit 604a9ed

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

AdysTech.InfluxDB.Client.Net/InfluxDBClient.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,29 +399,32 @@ public async Task<bool> PostPointAsync(string dbName, IInfluxDatapoint point)
399399
/// </summary>
400400
/// <param name="dbName">InfluxDB database name</param>
401401
/// <param name="Points">Collection of Influx data points to be written</param>
402-
/// <returns>True:Success, False:Failure</returns>
402+
/// <returns>True:Success, False:Failure, or partial failure</returns>
403+
/// Sets Saved property on InfluxDatapoint to true to successful points
403404
///<exception cref="UnauthorizedAccessException">When Influx needs authentication, and no user name password is supplied or auth fails</exception>
404405
///<exception cref="HttpRequestException">all other HTTP exceptions</exception>
405406
public async Task<bool> PostPointsAsync(string dbName, IEnumerable<IInfluxDatapoint> Points)
406407
{
407408
int maxBatchSize = 255;
408-
409+
bool finalResult = true, result;
409410
foreach ( var group in Points.GroupBy (p => p.Precision) )
410411
{
411412
var pointsGroup = group.AsEnumerable ().Select ((point, index) => new { Index = index, Point = point })//get the index of each point
412413
.GroupBy (x => x.Index / maxBatchSize) //chunk into smaller batches
413414
.Select (x => x.Select (v => v.Point)); //get the points
414415
foreach ( var points in pointsGroup )
415416
{
416-
if ( await PostPointsAsync (dbName, group.Key, points) )
417+
result = await PostPointsAsync (dbName, group.Key, points);
418+
finalResult = result && finalResult;
419+
if ( result )
417420
{
418421
points.ToList ().ForEach (p => p.Saved = true);
419422
}
420423
}
421424

422425
}
423426

424-
return true;
427+
return finalResult;
425428
}
426429

427430

0 commit comments

Comments
 (0)