// Copyright (c) Microsoft. All rights reserved.
using System.Threading.Tasks;
using Microsoft.Shared.Diagnostics;
namespace Microsoft.Agents.AI.Workflows;
///
/// Represents the workflow binding details for a shared executor instance, including configuration options
/// for event emission.
///
/// The executor instance to bind. Cannot be null.
public record ExecutorInstanceBinding(Executor ExecutorInstance)
: ExecutorBinding(Throw.IfNull(ExecutorInstance).Id,
(_) => new(ExecutorInstance),
ExecutorInstance.GetType(),
ExecutorInstance)
{
///
public override bool SupportsConcurrentSharedExecution => this.ExecutorInstance.IsCrossRunShareable;
///
public override bool SupportsResetting => this.ExecutorInstance is IResettableExecutor;
///
public override bool IsSharedInstance => true;
///
protected override async ValueTask ResetCoreAsync()
{
if (this.ExecutorInstance is IResettableExecutor resettable)
{
await resettable.ResetAsync().ConfigureAwait(false);
return true;
}
return false;
}
}