mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
.NET: [BREAKING] Propagate CancellationToken into Workflow Executors and message handlers (#1280)
* feat: Propagate CancellationToken to Executors * Also adds cancellation propagation to `Executor`-accessible APIs * Adds registrators for cancellable handlers to `RouteBuilder` * [BREAKING]: Adds `CancellationToken` to `IMessageHandler.HandleAsync` * test: Re-enable Concurrent Orchestration test * refactor: Delete unused IInputCoordinator * refactor: Remove superfluous argument qualifications
This commit is contained in:
+4
-3
@@ -132,7 +132,7 @@ public static class IWorkflowContextExtensions
|
||||
/// <returns>The converted value</returns>
|
||||
public static async ValueTask<object?> ConvertValueAsync(this IWorkflowContext context, VariableType targetType, string key, string? scopeName = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
object? sourceValue = await context.ReadStateAsync<object>(key, scopeName).ConfigureAwait(false);
|
||||
object? sourceValue = await context.ReadStateAsync<object>(key, scopeName, cancellationToken).ConfigureAwait(false);
|
||||
return sourceValue.ConvertType(targetType);
|
||||
}
|
||||
|
||||
@@ -143,10 +143,11 @@ public static class IWorkflowContextExtensions
|
||||
/// <param name="context">The workflow execution context used to restore persisted state prior to formatting.</param>
|
||||
/// <param name="key">The key of the state value.</param>
|
||||
/// <param name = "scopeName" > An optional name that specifies the scope to read.If null, the default scope is used.</param>
|
||||
/// <param name="cancellationToken">A token that propagates notification when operation should be canceled.</param>
|
||||
/// <returns>The evaluated list expression</returns>
|
||||
public static async ValueTask<IList<TElement>?> ReadListAsync<TElement>(this IWorkflowContext context, string key, string? scopeName = null)
|
||||
public static async ValueTask<IList<TElement>?> ReadListAsync<TElement>(this IWorkflowContext context, string key, string? scopeName = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
object? value = await context.ReadStateAsync<object>(key, scopeName).ConfigureAwait(false);
|
||||
object? value = await context.ReadStateAsync<object>(key, scopeName, cancellationToken).ConfigureAwait(false);
|
||||
return value.AsList<TElement>();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user