Skip to content

Commit 4056f64

Browse files
Undo accidental deletion of the ProviderUtils class (#1750)
Co-authored-by: Varshi Bachu <[email protected]>
1 parent 6eeedbf commit 4056f64

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
using DurableTask.Core;
9+
using Newtonsoft.Json;
10+
using Newtonsoft.Json.Linq;
11+
12+
namespace Microsoft.Azure.WebJobs.Extensions.DurableTask
13+
{
14+
/// <summary>
15+
/// Provides access to internal functionality for the purpose of implementing durability providers.
16+
/// </summary>
17+
public static class ProviderUtils
18+
{
19+
/// <summary>
20+
/// Returns the instance id of the entity scheduler for a given entity id.
21+
/// </summary>
22+
/// <param name="entityId">The entity id.</param>
23+
/// <returns>The instance id of the scheduler.</returns>
24+
public static string GetSchedulerIdFromEntityId(EntityId entityId)
25+
{
26+
return EntityId.GetSchedulerIdFromEntityId(entityId);
27+
}
28+
29+
/// <summary>
30+
/// Reads the state of an entity from the serialized entity scheduler state.
31+
/// </summary>
32+
/// <param name="state">The orchestration state of the scheduler.</param>
33+
/// <param name="serializerSettings">The serializer settings.</param>
34+
/// <param name="result">The serialized state of the entity.</param>
35+
/// <returns>true if the entity exists, false otherwise.</returns>
36+
public static bool TryGetEntityStateFromSerializedSchedulerState(OrchestrationState state, JsonSerializerSettings serializerSettings, out string result)
37+
{
38+
if (state != null
39+
&& state.OrchestrationInstance != null
40+
&& state.Input != null)
41+
{
42+
var schedulerState = JsonConvert.DeserializeObject<SchedulerState>(state.Input, serializerSettings);
43+
44+
if (schedulerState.EntityExists)
45+
{
46+
result = schedulerState.EntityState;
47+
return true;
48+
}
49+
}
50+
51+
result = null;
52+
return false;
53+
}
54+
55+
/// <summary>
56+
/// Converts the DTFx representation of the orchestration state into the DF representation.
57+
/// </summary>
58+
/// <param name="orchestrationState">The orchestration state.</param>
59+
/// <returns>The orchestration status.</returns>
60+
public static DurableOrchestrationStatus ConvertOrchestrationStateToStatus(OrchestrationState orchestrationState)
61+
{
62+
return DurableClient.ConvertOrchestrationStateToStatus(orchestrationState);
63+
}
64+
}
65+
}

src/WebJobs.Extensions.DurableTask/WebJobs.Extensions.DurableTask.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<RootNamespace>Microsoft.Azure.WebJobs.Extensions.DurableTask</RootNamespace>
77
<MajorVersion>2</MajorVersion>
88
<MinorVersion>4</MinorVersion>
9-
<PatchVersion>2</PatchVersion>
9+
<PatchVersion>3</PatchVersion>
1010
<Version>$(MajorVersion).$(MinorVersion).$(PatchVersion)</Version>
1111
<FileVersion>$(MajorVersion).$(MinorVersion).$(PatchVersion)</FileVersion>
1212
<AssemblyVersion>$(MajorVersion).0.0.0</AssemblyVersion>

0 commit comments

Comments
 (0)