Skip to content

Commit

Permalink
(GH-368) Improve xml comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Jan 28, 2021
1 parent 8ef7313 commit 4853235
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Source/StrongGrid/Extensions/Public.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,19 @@ public static async Task<IpAddress[]> GetUnassignedAsync(this IIpAddresses ipAdd

while (true)
{
// Retrieve 500 ip addresses at a time (that's the maximum SendGrid allow us to retrieve at a time)
var allIpAddresses = await ipAddresses.GetAllAsync(limit: Utils.MaxSendGridPagingLimit, offset: currentOffset, cancellationToken: cancellationToken).ConfigureAwait(false);

// Take the addresses that have not been added to a pool
unassignedIpAddresses.AddRange(allIpAddresses.Records.Where(ip => ip.Pools == null || !ip.Pools.Any()));

// Stop if we have enough unassigned addresses
if (unassignedIpAddresses.Count >= offset + limit) break;

// Stop if there are no more addresses to fetch
if (allIpAddresses.Next == null) break;

// Increase the offset so we retrieve the next set of 500 addresses
currentOffset += Utils.MaxSendGridPagingLimit;
}

Expand Down

0 comments on commit 4853235

Please sign in to comment.