Skip to content

Commit af7a4c8

Browse files
committed
enhance
1 parent 4f0e5e3 commit af7a4c8

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

src/Abstractions/Entities/TaskEntityContext.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ public abstract string ScheduleNewOrchestration(
6060
/// <param name="name">The name of the orchestration to start.</param>
6161
/// <param name="input">The input for the orchestration.</param>
6262
/// <param name="options">The options for starting the orchestration.</param>
63-
/// <returns>The instance id for the new orchestration.</returns>
64-
public virtual async Task<string> ScheduleNewOrchestrationAsync(TaskName name, object? input = null, StartOrchestrationOptions? options = null)
63+
/// <returns>A task representing the asynchronous operation.</returns>
64+
public virtual Task<string> ScheduleNewOrchestrationAsync(
65+
TaskName name,
66+
object? input = null,
67+
StartOrchestrationOptions? options = null)
6568
{
66-
return await Task.FromResult(this.ScheduleNewOrchestration(name, input, options));
69+
return Task.FromResult(this.ScheduleNewOrchestration(name, input, options));
6770
}
6871
}

src/Abstractions/Entities/TaskEntityState.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,15 @@ public abstract class TaskEntityState
5959
/// </summary>
6060
/// <param name="state">The state to set.</param>
6161
public abstract void SetState(object? state);
62+
63+
/// <summary>
64+
/// Asynchronously sets the entity state. Setting of <c>null</c> will delete entity state.
65+
/// </summary>
66+
/// <param name="state">The state to set.</param>
67+
/// <returns>A task representing the asynchronous operation.</returns>
68+
public virtual Task SetStateAsync(object? state)
69+
{
70+
this.SetState(state);
71+
return Task.CompletedTask;
72+
}
6273
}

src/Worker/Core/Shims/TaskEntityShim.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,13 @@ public void Reset()
190190
return this.cachedValue;
191191
}
192192

193-
public override async void SetState(object? state)
193+
public override void SetState(object? state)
194+
{
195+
this.value = this.dataConverter.Serialize(state);
196+
this.cachedValue = state;
197+
}
198+
199+
public override async Task SetStateAsync(object? state)
194200
{
195201
this.value = this.enableLargePayloadSupport
196202
? await this.dataConverter.SerializeAsync(state)
@@ -281,7 +287,10 @@ public override string ScheduleNewOrchestration(TaskName name, object? input = n
281287
return instanceId;
282288
}
283289

284-
public override async Task<string> ScheduleNewOrchestrationAsync(TaskName name, object? input = null, StartOrchestrationOptions? options = null)
290+
public override async Task<string> ScheduleNewOrchestrationAsync(
291+
TaskName name,
292+
object? input = null,
293+
StartOrchestrationOptions? options = null)
285294
{
286295
Check.NotEntity(true, options?.InstanceId);
287296

test/Abstractions.Tests/Entities/Mocks/TestEntityState.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,10 @@ public override void SetState(object? state)
2828
{
2929
this.State = state;
3030
}
31+
32+
public override Task SetStateAsync(object? state)
33+
{
34+
this.SetState(state);
35+
return Task.CompletedTask;
36+
}
3137
}

0 commit comments

Comments
 (0)