mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
32e7ff00b5
* feat: Add support for Workflow-as-Executor * Fixes routing of 'object' compile-typed variables to properly take in type information * Fixes a concurrency issue in StepTracer * fix: Make Subworkflow ExternalRequests work properly * fix: Threading and Concurrency fixes; prep for OffThread Mode * refactor: Remove dead code around OffStreamRunEventStream Currently not used, and will be replaced with a rewrite when brought back, so having it in the change is not valuable. * ci: Work around issues with dotnet-format not properly analyzing the source * fix: Fix the logic of AsyncCoordinator and AsyncBarrier * Prevent individual wait cancellations from canceling the entire barrier * Propagate information about whether the wait was completed or cancelled, and whether any waiters were present when released * fix: Remove superfluous acces to .Keys in InProcStepTracer * refactor: Clean up AsyncCoordinator's use of AsyncBarrier
41 lines
1.5 KiB
C#
41 lines
1.5 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Microsoft.Shared.Diagnostics;
|
|
|
|
namespace Microsoft.Agents.AI.Workflows.Execution;
|
|
|
|
internal sealed class DeliveryMapping
|
|
{
|
|
private readonly IEnumerable<MessageEnvelope> _envelopes;
|
|
private readonly IEnumerable<Executor> _targets;
|
|
|
|
public DeliveryMapping(IEnumerable<MessageEnvelope> envelopes, IEnumerable<Executor> targets)
|
|
{
|
|
this._envelopes = Throw.IfNull(envelopes);
|
|
this._targets = Throw.IfNull(targets);
|
|
}
|
|
|
|
public DeliveryMapping(MessageEnvelope envelope, Executor target) : this([envelope], [target]) { }
|
|
public DeliveryMapping(MessageEnvelope envelope, IEnumerable<Executor> targets) : this([envelope], targets) { }
|
|
public DeliveryMapping(IEnumerable<MessageEnvelope> envelopes, Executor target) : this(envelopes, [target]) { }
|
|
|
|
public IEnumerable<MessageDelivery> Deliveries => from target in this._targets
|
|
from envelope in this._envelopes
|
|
select new MessageDelivery(envelope, target);
|
|
|
|
public void MapInto(StepContext nextStep)
|
|
{
|
|
foreach (Executor target in this._targets)
|
|
{
|
|
ConcurrentQueue<MessageEnvelope> messageQueue = nextStep.MessagesFor(target.Id);
|
|
foreach (MessageEnvelope envelope in this._envelopes)
|
|
{
|
|
messageQueue.Enqueue(envelope);
|
|
}
|
|
}
|
|
}
|
|
}
|