Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DurableTask.Core/DurableTask.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<!-- Version Info -->
<PropertyGroup>
<MajorVersion>3</MajorVersion>
<MinorVersion>0</MinorVersion>
<MinorVersion>1</MinorVersion>
<PatchVersion>0</PatchVersion>
<VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
<FileVersion>$(VersionPrefix).0</FileVersion>
Expand Down
6 changes: 5 additions & 1 deletion src/DurableTask.Core/TaskActivityDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ await this.dispatchPipeline.RunAsync(dispatchContext, async _ =>
throw new TypeMissingException($"TaskActivity {scheduledEvent.Name} version {scheduledEvent.Version} was not found");
}

var context = new TaskContext(taskMessage.OrchestrationInstance);
var context = new TaskContext(
taskMessage.OrchestrationInstance,
scheduledEvent.Name,
scheduledEvent.Version,
scheduledEvent.EventId);
context.ErrorPropagationMode = this.errorPropagationMode;

HistoryEvent? responseEvent;
Expand Down
28 changes: 27 additions & 1 deletion src/DurableTask.Core/TaskContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

#nullable enable
namespace DurableTask.Core
{
/// <summary>
Expand All @@ -23,15 +23,41 @@ public class TaskContext
/// </summary>
/// <param name="orchestrationInstance"></param>
public TaskContext(OrchestrationInstance orchestrationInstance)
: this(orchestrationInstance, string.Empty, null, -1)
{
}

/// <summary>
/// Creates a new TaskContext with the supplied OrchestrationInstance and taskId
/// </summary>
public TaskContext(OrchestrationInstance orchestrationInstance, string name, string? version, int taskId)
{
OrchestrationInstance = orchestrationInstance;
Name = name;
Version = version;
TaskId = taskId;
}

/// <summary>
/// Gets the OrchestrationInstance for this task context
/// </summary>
public OrchestrationInstance OrchestrationInstance { get; private set; }

/// <summary>
/// Gets the name of the task
/// </summary>
public string Name { get; }

/// <summary>
/// Gets the version of the task, if any.
/// </summary>
public string? Version { get; }

/// <summary>
/// Gets the ID of the task, which is a sequential number unique to the orchestration instance.
/// </summary>
public int TaskId { get; }

/// <summary>
/// Gets or sets a value indicating how to propagate unhandled exception metadata.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions src/DurableTask.Core/TaskOrchestrationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ public override Task<T> CreateTimer<T>(DateTime fireAt, T state)

public override async Task<T> CreateTimer<T>(DateTime fireAt, T state, CancellationToken cancelToken)
{
if (state is CancellationToken)
{
throw new ArgumentException(
"The state parameter cannot be a CancellationToken. Did you mean to use a different overload?",
paramName: nameof(state));
}

int id = this.idCounter++;
var createTimerOrchestratorAction = new CreateTimerOrchestratorAction
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3148,7 +3148,7 @@ public override async Task<string> RunTask(OrchestrationContext context, TimeSpa
using (var cts = new CancellationTokenSource())
{
Task<bool> approvalTask = this.GetWaitForApprovalTask();
Task timeoutTask = context.CreateTimer(deadline, cts.Token);
Task timeoutTask = context.CreateTimer(deadline, true, cts.Token);

if (shouldFail)
{
Expand Down
Loading