Skip to content

Commit fc4c801

Browse files
authored
Remove obsolete lambda-activity for now (#94)
1 parent 4ed1b41 commit fc4c801

File tree

4 files changed

+15
-65
lines changed

4 files changed

+15
-65
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- `TaskOrchestrationContext.CreateReplaySafeLogger` now creates `ILogger` directly (as opposed to wrapping an existing `ILogger`).
66
- Durable Functions class-based syntax now resolves `ITaskActivity` instances from `IServiceProvider`, if available there.
77
- `DurableTaskClient` methods have been touched up to ensure `CancellationToken` is included, as well as is the last parameter.
8+
- Removed obsolete/unimplemented local lambda activity calls from `TaskOrchestrationContext`
89

910
## v1.0.0-rc.1
1011

src/Abstractions/TaskOrchestrationContext.cs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,6 @@ public virtual Task CallActivityAsync(TaskName name, object? input = null, TaskO
118118
/// <inheritdoc cref="CallActivityAsync"/>
119119
public abstract Task<T> CallActivityAsync<T>(TaskName name, object? input = null, TaskOptions? options = null);
120120

121-
/// <summary>
122-
/// Asynchronously invokes an activity function on the current machine.
123-
/// </summary>
124-
/// <remarks>
125-
/// <para>
126-
/// Unlike named activities, anonymous activities are triggered in local memory and always run in the same process
127-
/// space as the calling orchestrators. If a machine failure occurs before the anonymous activity completes, then
128-
/// the previous orchestration execution will be re-run to re-schedule the anonymous activity.
129-
/// </para>
130-
/// </remarks>
131-
/// <inheritdoc cref="CallActivityAsync{T}(TaskName, object?, TaskOptions?)"/>
132-
[Obsolete("This method is not yet fully implemented")]
133-
public abstract Task<T> CallActivityAsync<T>(
134-
Func<object?, T> activityLambda, object? input = null, TaskOptions? options = null);
135-
136121
/// <summary>
137122
/// Creates a durable timer that expires after the specified delay.
138123
/// </summary>
@@ -267,9 +252,7 @@ public async Task<T> WaitForExternalEvent<T>(string eventName, TimeSpan timeout)
267252
/// </typeparam>
268253
/// <inheritdoc cref="CallSubOrchestratorAsync(TaskName, object?, TaskOptions?)"/>
269254
public abstract Task<TResult> CallSubOrchestratorAsync<TResult>(
270-
TaskName orchestratorName,
271-
object? input = null,
272-
TaskOptions? options = null);
255+
TaskName orchestratorName, object? input = null, TaskOptions? options = null);
273256

274257
/// <summary>
275258
/// Executes a named sub-orchestrator.
@@ -314,9 +297,7 @@ public abstract Task<TResult> CallSubOrchestratorAsync<TResult>(
314297
/// <see cref="TaskFailedException.FailureDetails"/> property.
315298
/// </exception>
316299
public Task CallSubOrchestratorAsync(
317-
TaskName orchestratorName,
318-
object? input = null,
319-
TaskOptions? options = null)
300+
TaskName orchestratorName, object? input = null, TaskOptions? options = null)
320301
{
321302
return this.CallSubOrchestratorAsync<object>(orchestratorName, input, options);
322303
}

src/Worker/Core/Shims/TaskOrchestrationContextWrapper.cs

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ sealed partial class TaskOrchestrationContextWrapper : TaskOrchestrationContext
1616
{
1717
readonly Dictionary<string, IEventSource> externalEventSources = new(StringComparer.OrdinalIgnoreCase);
1818
readonly NamedQueue<string> externalEventBuffer = new();
19-
readonly Queue<Action> localActivityCalls = new();
20-
2119
readonly OrchestrationContext innerContext;
2220
readonly OrchestrationInvocationContext invocationContext;
2321
readonly ILogger logger;
@@ -115,33 +113,6 @@ public override async Task<T> CallActivityAsync<T>(
115113
}
116114
}
117115

118-
/// <inheritdoc/>
119-
[Obsolete("This method is not yet fully implemented")]
120-
public override Task<T> CallActivityAsync<T>(
121-
Func<object?, T> activityLambda, object? input = null, TaskOptions? options = null)
122-
{
123-
if (options != null)
124-
{
125-
throw new NotImplementedException($"{nameof(TaskOptions)} are not yet supported.");
126-
}
127-
128-
TaskCompletionSource<T> tcs = new();
129-
this.localActivityCalls.Enqueue(() =>
130-
{
131-
try
132-
{
133-
T output = activityLambda(input);
134-
tcs.SetResult(output);
135-
}
136-
catch (Exception ex)
137-
{
138-
tcs.SetException(ex);
139-
}
140-
});
141-
142-
return tcs.Task;
143-
}
144-
145116
/// <inheritdoc/>
146117
public override async Task<TResult> CallSubOrchestratorAsync<TResult>(
147118
TaskName orchestratorName,
@@ -328,20 +299,6 @@ static void SwapByteArrayElements(byte[] byteArray, int left, int right)
328299
return new Guid(newGuidByteArray);
329300
}
330301

331-
/// <summary>
332-
/// Invokes all queued local activity calls.
333-
/// </summary>
334-
internal void ExecuteLocalActivityCalls()
335-
{
336-
while (this.localActivityCalls.Count > 0)
337-
{
338-
Action localActivityLambda = this.localActivityCalls.Dequeue();
339-
340-
// Exceptions are never expected to escape here
341-
localActivityLambda.Invoke();
342-
}
343-
}
344-
345302
/// <summary>
346303
/// Completes the external event by name, allowing the orchestration to continue if it is waiting on this event.
347304
/// </summary>

test/Grpc.IntegrationTests/GrpcDurableTaskClientIntegrationTests.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
using System.Diagnostics.CodeAnalysis;
45
using FluentAssertions;
56
using FluentAssertions.Execution;
67
using Microsoft.DurableTask.Client;
@@ -139,7 +140,10 @@ await server.Client.ScheduleNewOrchestrationInstanceAsync(
139140

140141
List<OrchestrationMetadata> left = resumedPages.SelectMany(p => p.Values).ToList();
141142
List<OrchestrationMetadata> right = pages.Skip(2).SelectMany(p => p.Values).ToList();
142-
left.Should().BeEquivalentTo(right, cfg => cfg.Including(x => x.InstanceId).Including(x => x.CreatedAt));
143+
left.Should().BeEquivalentTo(
144+
right,
145+
cfg => cfg.Including(x => x.InstanceId).Including(x => x.CreatedAt)
146+
.Using<DateTimeOffset, DateTimeToleranceComparer>());
143147

144148
Page<OrchestrationMetadata> page = await pageable.AsPages(pageSizeHint: 10).FirstAsync();
145149
page.Values.Should().HaveCount(10);
@@ -165,4 +169,11 @@ static async Task<string> Orchestration(TaskOrchestrationContext context, bool s
165169
b.AddTasks(tasks => tasks.AddOrchestratorFunc<bool, string>(OrchestrationName, Orchestration));
166170
});
167171
}
172+
173+
class DateTimeToleranceComparer : IEqualityComparer<DateTimeOffset>
174+
{
175+
public bool Equals(DateTimeOffset x, DateTimeOffset y) => (x - y).Duration() < TimeSpan.FromMilliseconds(100);
176+
177+
public int GetHashCode([DisallowNull] DateTimeOffset obj) => obj.GetHashCode();
178+
}
168179
}

0 commit comments

Comments
 (0)