Add YieldOutputAsync calls to 05_WorkflowEvents sample executors

The integration test asserts that WorkflowOutputEvent is found in the
stream, but the sample executors only used AddEventAsync for custom
events and never called YieldOutputAsync. Since WorkflowOutputEvent is
only emitted via explicit YieldOutputAsync calls, the assertion would
fail. Added YieldOutputAsync to each executor to match the test
expectation and demonstrate the API in the sample.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Shyju Krishnankutty
2026-02-17 19:06:46 -08:00
Unverified
parent 13e53eec8f
commit 1d0e44fb86
@@ -40,7 +40,7 @@ internal sealed record Order(string Id, DateTime OrderDate, bool IsCancelled, st
internal sealed record Customer(string Name, string Email);
// ═══════════════════════════════════════════════════════════════════════════════
// Executors - emit events via IWorkflowContext.AddEventAsync
// Executors - emit events via AddEventAsync and YieldOutputAsync
// ═══════════════════════════════════════════════════════════════════════════════
/// <summary>
@@ -67,6 +67,9 @@ internal sealed class OrderLookup() : Executor<string, Order>("OrderLookup")
await context.AddEventAsync(new OrderFoundEvent(order.Customer.Name), cancellationToken);
// YieldOutputAsync emits a WorkflowOutputEvent observable via streaming
await context.YieldOutputAsync(order, cancellationToken);
return order;
}
}
@@ -96,6 +99,8 @@ internal sealed class OrderCancel() : Executor<Order, Order>("OrderCancel")
await context.AddEventAsync(new CancellationProgressEvent(100, "Complete"), cancellationToken);
await context.AddEventAsync(new OrderCancelledEvent(), cancellationToken);
await context.YieldOutputAsync(cancelledOrder, cancellationToken);
return cancelledOrder;
}
}
@@ -117,6 +122,8 @@ internal sealed class SendEmail() : Executor<Order, string>("SendEmail")
await context.AddEventAsync(new EmailSentEvent(message.Customer.Email), cancellationToken);
await context.YieldOutputAsync(result, cancellationToken);
return result;
}
}