refactor(client)!: return Task from EmailSender.Send
Await ISendingEmailPublisher.EnqueueAsync so publish failures surface to the caller instead of being lost in a fire-and-forget call. BREAKING CHANGE: EmailSender.Send now returns Task and must be awaited. Synchronous callers that relied on exceptions being thrown directly from Send will no longer observe them.
This commit is contained in:
@@ -120,13 +120,13 @@ public static class EmailSender
|
|||||||
/// Ensure that any unhandled exceptions from the async operation are handled
|
/// Ensure that any unhandled exceptions from the async operation are handled
|
||||||
/// at the publisher level.
|
/// at the publisher level.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static void Send(EmailContext email)
|
public static async Task Send(EmailContext email)
|
||||||
{
|
{
|
||||||
if(!IsConnected)
|
if(!IsConnected)
|
||||||
throw new InvalidOperationException("Messaging service is not connected. Call ConnectRabbitMq first.");
|
throw new InvalidOperationException("Messaging service is not connected. Call ConnectRabbitMq first.");
|
||||||
|
|
||||||
var publisher = LazyProvider.Value.GetRequiredService<ISendingEmailPublisher>();
|
var publisher = LazyProvider.Value.GetRequiredService<ISendingEmailPublisher>();
|
||||||
publisher.EnqueueAsync(new SendingEmailEvent()
|
await publisher.EnqueueAsync(new SendingEmailEvent()
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
Mail = email,
|
Mail = email,
|
||||||
|
|||||||
Reference in New Issue
Block a user