From c956f2a4cc8100a163c9ee0dcf45e67fb39fdb39 Mon Sep 17 00:00:00 2001 From: Thomas Blitz Date: Fri, 13 Nov 2020 11:52:18 +0100 Subject: [PATCH 1/2] Set a max PollDelay on Bulk Job operations --- src/ForceToolkitForNET/ForceClient.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ForceToolkitForNET/ForceClient.cs b/src/ForceToolkitForNET/ForceClient.cs index b30135cf..14ab50fa 100644 --- a/src/ForceToolkitForNET/ForceClient.cs +++ b/src/ForceToolkitForNET/ForceClient.cs @@ -319,6 +319,7 @@ public async Task> RunJobAndPollAsync(string objectName { const float pollingStart = 1000; const float pollingIncrease = 2.0f; + const float maxPollDeplay = 20000; var batchInfoResults = await RunJobAsync(objectName, externalIdFieldName, operationType, recordsLists); @@ -345,6 +346,7 @@ public async Task> RunJobAndPollAsync(string objectName await Task.Delay((int)currentPoll); currentPoll *= pollingIncrease; + if (currentPoll > maxPollDeplay) currentPoll = maxPollDeplay; } From c7388fd413a654bb03d205e5e1aead81e83a5716 Mon Sep 17 00:00:00 2001 From: Thomas Blitz Date: Fri, 13 Nov 2020 12:01:06 +0100 Subject: [PATCH 2/2] Update interface and make it the max delay completely optional --- src/ForceToolkitForNET/ForceClient.cs | 9 ++++----- src/ForceToolkitForNET/IForceClient.cs | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ForceToolkitForNET/ForceClient.cs b/src/ForceToolkitForNET/ForceClient.cs index 14ab50fa..3feecf88 100644 --- a/src/ForceToolkitForNET/ForceClient.cs +++ b/src/ForceToolkitForNET/ForceClient.cs @@ -309,17 +309,16 @@ public async Task> RunJobAsync(string objectName, strin } public async Task> RunJobAndPollAsync(string objectName, BulkConstants.OperationType operationType, - IEnumerable> recordsLists) + IEnumerable> recordsLists, float? maxPollDelayMilliSeconds = null) { - return await RunJobAndPollAsync(objectName, null, operationType, recordsLists); + return await RunJobAndPollAsync(objectName, null, operationType, recordsLists, maxPollDelayMilliSeconds); } public async Task> RunJobAndPollAsync(string objectName, string externalIdFieldName, BulkConstants.OperationType operationType, - IEnumerable> recordsLists) + IEnumerable> recordsLists, float? maxPollDelayMilliSeconds = null) { const float pollingStart = 1000; const float pollingIncrease = 2.0f; - const float maxPollDeplay = 20000; var batchInfoResults = await RunJobAsync(objectName, externalIdFieldName, operationType, recordsLists); @@ -346,7 +345,7 @@ public async Task> RunJobAndPollAsync(string objectName await Task.Delay((int)currentPoll); currentPoll *= pollingIncrease; - if (currentPoll > maxPollDeplay) currentPoll = maxPollDeplay; + if (maxPollDelayMilliSeconds != null && currentPoll > maxPollDelayMilliSeconds) currentPoll = (float)maxPollDelayMilliSeconds; } diff --git a/src/ForceToolkitForNET/IForceClient.cs b/src/ForceToolkitForNET/IForceClient.cs index aa53de42..98adc3f7 100644 --- a/src/ForceToolkitForNET/IForceClient.cs +++ b/src/ForceToolkitForNET/IForceClient.cs @@ -41,7 +41,7 @@ public interface IForceClient : IDisposable // BULK Task> RunJobAsync(string objectName, BulkConstants.OperationType operationType, IEnumerable> recordsLists); - Task> RunJobAndPollAsync(string objectName, BulkConstants.OperationType operationType, IEnumerable> recordsLists); + Task> RunJobAndPollAsync(string objectName, BulkConstants.OperationType operationType, IEnumerable> recordsLists, float? maxPollDelayMilliSeconds = null); Task CreateJobAsync(string objectName, BulkConstants.OperationType operationType); Task CreateJobBatchAsync(JobInfoResult jobInfo, ISObjectList recordsObject); Task CreateJobBatchAsync(string jobId, ISObjectList recordsObject);