Skip to content

Commit b5e8500

Browse files
committed
up
1 parent 49b615d commit b5e8500

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

src/ScheduledTasks/Client/ScheduledTaskClientImpl.cs

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using Microsoft.DurableTask.Client;
55
using Microsoft.DurableTask.Client.Entities;
6-
using Microsoft.DurableTask.Entities;
76
using Microsoft.Extensions.Logging;
87

98
namespace Microsoft.DurableTask.ScheduledTasks;
@@ -57,32 +56,16 @@ public override async Task<ScheduleClient> CreateScheduleAsync(ScheduleCreationO
5756

5857
try
5958
{
60-
EntityInstanceId entityId = new EntityInstanceId(nameof(Schedule), scheduleId);
61-
EntityMetadata<ScheduleState>? metadata = await this.durableTaskClient.Entities.GetEntityAsync<ScheduleState>(entityId, cancellation);
59+
// Get schedule client first
60+
ScheduleClient scheduleClient = this.GetScheduleClient(scheduleId);
6261

63-
if (metadata == null || metadata.State.Status == ScheduleStatus.Uninitialized)
64-
{
65-
return null;
66-
}
67-
68-
ScheduleState state = metadata.State;
69-
ScheduleConfiguration? config = state.ScheduleConfiguration;
70-
71-
return new ScheduleDescription
72-
{
73-
ScheduleId = scheduleId,
74-
OrchestrationName = config?.OrchestrationName,
75-
OrchestrationInput = config?.OrchestrationInput,
76-
OrchestrationInstanceId = config?.OrchestrationInstanceId,
77-
StartAt = config?.StartAt,
78-
EndAt = config?.EndAt,
79-
Interval = config?.Interval,
80-
StartImmediatelyIfLate = config?.StartImmediatelyIfLate,
81-
Status = state.Status,
82-
ExecutionToken = state.ExecutionToken,
83-
LastRunAt = state.LastRunAt,
84-
NextRunAt = state.NextRunAt,
85-
};
62+
// Call DescribeAsync which handles all the entity state mapping
63+
return await scheduleClient.DescribeAsync(cancellation);
64+
}
65+
catch (ScheduleNotFoundException)
66+
{
67+
// Return null if schedule not found
68+
return null;
8669
}
8770
catch (OperationCanceledException) when (cancellation.IsCancellationRequested)
8871
{

0 commit comments

Comments
 (0)