Skip to content

Commit

Permalink
Run continuations synchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
slang25 committed Oct 14, 2024
1 parent 2c9c8d6 commit c78e88a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/LocalSqsSnsMessaging/SnsClient/InMemorySnsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public async Task<string> SubscribeQueueAsync(string topicArn, ICoreAmazonSQS sq
ArgumentNullException.ThrowIfNull(sqsClient);

// Get the queue's existing policy
var queueAttributes = await sqsClient.GetAttributesAsync(sqsQueueUrl).ConfigureAwait(false);
var queueAttributes = await sqsClient.GetAttributesAsync(sqsQueueUrl).ConfigureAwait(true);

var sqsQueueArn = queueAttributes["QueueArn"];

Expand All @@ -61,10 +61,10 @@ public async Task<string> SubscribeQueueAsync(string topicArn, ICoreAmazonSQS sq
TopicArn = topicArn,
Protocol = "sqs",
Endpoint = sqsQueueArn,
}).ConfigureAwait(false);
}).ConfigureAwait(true);

var setAttributes = new Dictionary<string, string> { { "Policy", policy.ToJson() } };
await sqsClient.SetAttributesAsync(sqsQueueUrl, setAttributes).ConfigureAwait(false);
await sqsClient.SetAttributesAsync(sqsQueueUrl, setAttributes).ConfigureAwait(true);

return response.SubscriptionArn;
}
Expand All @@ -77,7 +77,7 @@ public async Task<IDictionary<string, string>> SubscribeQueueToTopicsAsync(IList
Dictionary<string, string> topicSubscriptionMapping = new();
foreach (var topicArn in topicArns)
{
var subscriptionArn = await SubscribeQueueAsync(topicArn, sqsClient, sqsQueueUrl).ConfigureAwait(false);
var subscriptionArn = await SubscribeQueueAsync(topicArn, sqsClient, sqsQueueUrl).ConfigureAwait(true);
topicSubscriptionMapping.Add(topicArn, subscriptionArn);
}

Expand Down
4 changes: 2 additions & 2 deletions src/LocalSqsSnsMessaging/SqsClient/InMemorySqsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public async Task<ReceiveMessageResponse> ReceiveMessageAsync(ReceiveMessageRequ

try
{
await reader.WaitToReadAsync(linkedToken.Token).ConfigureAwait(false);
await reader.WaitToReadAsync(linkedToken.Token).ConfigureAwait(true);
}
catch (OperationCanceledException)
{
Expand Down Expand Up @@ -562,7 +562,7 @@ private static Message CreateMessage(string messageBody, Dictionary<string, Mess

private async Task SendDelayedMessageAsync(SqsQueueResource queue, Message message, int delaySeconds)
{
await Task.Delay(TimeSpan.FromSeconds(delaySeconds), _bus.TimeProvider).ConfigureAwait(false);
await Task.Delay(TimeSpan.FromSeconds(delaySeconds), _bus.TimeProvider).ConfigureAwait(true);
queue.Messages.Writer.TryWrite(message);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public SqsReceiveMessageAsyncTestsLocalAwsMessaging()
protected override async Task AdvanceTime(TimeSpan timeSpan)
{
_timeProvider.Advance(timeSpan);
// Allow for continuations to complete
await Task.Delay(TimeSpan.FromMilliseconds(2));
await Task.CompletedTask;
}
}

0 comments on commit c78e88a

Please sign in to comment.