Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
Fixes two problems, needing to use indexers on a dynamic, and a logic…
Browse files Browse the repository at this point in the history
… error that prevented the durable log files from being processed. (#266)
  • Loading branch information
matthewDDennis authored and mivano committed Aug 20, 2019
1 parent 6b63825 commit 9d9930e
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<SentPayloadResult> SendPayloadAsync(List<string> payload)
return await SendPayloadAsync(payload, true);
}

public async Task<SentPayloadResult> SendPayloadAsync(List<string> payload,bool first)
public async Task<SentPayloadResult> SendPayloadAsync(List<string> payload, bool first)
{
try
{
Expand All @@ -45,10 +45,10 @@ public async Task<SentPayloadResult> SendPayloadAsync(List<string> payload,bool
if (response.Success)
{
var cleanPayload = new List<string>();
var invalidPayload = GetInvalidPayloadAsync(response, payload,out cleanPayload);
if ((cleanPayload?.Any() ?? false) && first)
var invalidPayload = GetInvalidPayloadAsync(response, payload, out cleanPayload);
if ((cleanPayload?.Any() == false) && first)
{
await SendPayloadAsync(cleanPayload,false);
await SendPayloadAsync(cleanPayload, false);
}

return new SentPayloadResult(response, true, invalidPayload);
Expand Down Expand Up @@ -85,16 +85,17 @@ private InvalidResult GetInvalidPayloadAsync(DynamicResponse baseResult, List<st
bool hasErrors = false;
foreach (dynamic item in items)
{
long? status = item.index?.status;
var itemIndex = item?["index"];
long? status = itemIndex?["status"];
i++;
if (!status.HasValue || status < 300)
{
continue;
}

hasErrors = true;
var id = item.index?._id;
var error = item.index?.error;
var id = itemIndex?["_id"];
var error = itemIndex?["error"];
if (int.TryParse(id.Split('_')[0], out int index))
{
SelfLog.WriteLine("Received failed ElasticSearch shipping result {0}: {1}. Failed payload : {2}.", status, error?.ToString(), payload.ElementAt(index * 2 + 1));
Expand Down

0 comments on commit 9d9930e

Please sign in to comment.