Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/runner/Synapse.Runner/Services/Executors/ListenTaskExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ protected override async Task DoExecuteAsync(CancellationToken cancellationToken
if (this.Task.Definition.Foreach == null)
{
var context = await this.Task.CorrelateAsync(cancellationToken).ConfigureAwait(false);
await this.SetResultAsync(context, this.Task.Definition.Then, cancellationToken).ConfigureAwait(false);
var events = this.Task.Definition.Listen.Read switch
{
EventReadMode.Data or EventReadMode.Raw => context.Events.Select(e => e.Value.Data),
EventReadMode.Envelope => context.Events.Select(e => e.Value.Data),
_ => throw new NotSupportedException($"The specified event read mode '{this.Task.Definition.Listen.Read}' is not supported")
};
await this.SetResultAsync(events, this.Task.Definition.Then, cancellationToken).ConfigureAwait(false);
}
else
{
Expand Down Expand Up @@ -107,7 +113,12 @@ protected virtual async Task OnStreamingEventAsync(IStreamedCloudEvent e)
]
};
var arguments = this.GetExpressionEvaluationArguments();
var eventData = e.Event as object;
var eventData = this.Task.Definition.Listen.Read switch
{
EventReadMode.Data or EventReadMode.Raw => e.Event.Data,
EventReadMode.Envelope => e.Event,
_ => throw new NotSupportedException($"The specified event read mode '{this.Task.Definition.Listen.Read}' is not supported")
};
if (this.Task.Definition.Foreach.Output?.As is string fromExpression) eventData = await this.Task.Workflow.Expressions.EvaluateAsync<object>(fromExpression, eventData ?? new(), arguments, this.CancellationTokenSource!.Token).ConfigureAwait(false);
else if (this.Task.Definition.Foreach.Output?.As != null) eventData = await this.Task.Workflow.Expressions.EvaluateAsync<object>(this.Task.Definition.Foreach.Output.As!, eventData ?? new(), arguments, this.CancellationTokenSource!.Token).ConfigureAwait(false);
if (this.Task.Definition.Foreach.Export?.As is string toExpression)
Expand Down
Loading