Skip to content

Commit 291a6ca

Browse files
committed
partial fb addressed
1 parent 3763f1a commit 291a6ca

15 files changed

+29
-71
lines changed

samples/ScheduleConsoleApp/Orchestrators/StockPriceOrchestrator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public override async Task<string> RunAsync(TaskOrchestrationContext context, st
1414
try
1515
{
1616
// Get current stock price
17-
decimal currentPrice = await context.CallActivityAsync<decimal>("GetStockPrice", symbol);
17+
decimal currentPrice = await context.CallGetStockPriceAsync(symbol);
1818

1919
logger.LogInformation("Current price for {symbol} is ${price:F2}", symbol, currentPrice);
2020

samples/ScheduleConsoleApp/Program.cs

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525

2626
// Enable scheduled tasks support
2727
builder.UseDurableTaskScheduler(connectionString);
28-
builder.EnableScheduledTasksSupport();
28+
builder.UseScheduledTasks();
2929
});
3030

3131
// Configure the client
3232
services.AddDurableTaskClient(builder =>
3333
{
3434
builder.UseDurableTaskScheduler(connectionString);
35-
builder.EnableScheduledTasksSupport();
35+
builder.UseScheduledTasks();
3636
});
3737

3838
// Configure console logging
@@ -62,28 +62,15 @@
6262
AsyncPageable<string> schedules = await scheduledTaskClient.ListScheduleIdsAsync(query);
6363

6464
// Initialize the continuation token
65-
string? continuationToken = null;
66-
await foreach (Page<string> page in schedules.AsPages(continuationToken))
65+
await foreach (string scheduleId in schedules)
6766
{
68-
foreach (string scheduleId in page.Values)
69-
{
70-
// Obtain the schedule handle for the current scheduleId
71-
IScheduleHandle handle = scheduledTaskClient.GetScheduleHandle(scheduleId);
72-
73-
// Delete the schedule
74-
await handle.DeleteAsync();
67+
// Obtain the schedule handle for the current scheduleId
68+
IScheduleHandle handle = scheduledTaskClient.GetScheduleHandle(scheduleId);
7569

76-
Console.WriteLine($"Deleted schedule {scheduleId}");
77-
}
70+
// Delete the schedule
71+
await handle.DeleteAsync();
7872

79-
// Update the continuation token for the next iteration
80-
continuationToken = page.ContinuationToken;
81-
82-
// If there's no continuation token, we've reached the end of the collection
83-
if (continuationToken == null)
84-
{
85-
break;
86-
}
73+
Console.WriteLine($"Deleted schedule {scheduleId}");
8774
}
8875

8976

@@ -101,7 +88,7 @@
10188
ScheduleDescription scheduleDescription = await scheduleHandle.DescribeAsync();
10289

10390
// print the schedule description
104-
Console.WriteLine(scheduleDescription.ToJsonString(true));
91+
Console.WriteLine(scheduleDescription);
10592

10693
Console.WriteLine("");
10794
Console.WriteLine("");
@@ -111,7 +98,7 @@
11198
Console.WriteLine("\nPausing schedule...");
11299
await scheduleHandle.PauseAsync();
113100
scheduleDescription = await scheduleHandle.DescribeAsync();
114-
Console.WriteLine(scheduleDescription.ToJsonString(true));
101+
Console.WriteLine(scheduleDescription);
115102
Console.WriteLine("");
116103
Console.WriteLine("");
117104
Console.WriteLine("");
@@ -121,15 +108,13 @@
121108
Console.WriteLine("\nResuming schedule...");
122109
await scheduleHandle.ResumeAsync();
123110
scheduleDescription = await scheduleHandle.DescribeAsync();
124-
Console.WriteLine(scheduleDescription.ToJsonString(true));
111+
Console.WriteLine(scheduleDescription);
125112

126113
Console.WriteLine("");
127114
Console.WriteLine("");
128115
Console.WriteLine("");
129116

130117
await Task.Delay(TimeSpan.FromMinutes(30));
131-
//Console.WriteLine("\nPress any key to delete the schedule and exit...");
132-
//Console.ReadKey();
133118
}
134119
catch (Exception ex)
135120
{

samples/ScheduleWebApp/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
r.AddOrchestrator<CacheClearingOrchestrator>();
2424
});
2525
builder.UseDurableTaskScheduler(connectionString);
26-
builder.EnableScheduledTasksSupport();
26+
builder.UseScheduledTasks();
2727
});
2828

2929
// Register the client, which can be used to start orchestrations
3030
builder.Services.AddDurableTaskClient(builder =>
3131
{
3232
builder.UseDurableTaskScheduler(connectionString);
33-
builder.EnableScheduledTasksSupport();
33+
builder.UseScheduledTasks();
3434
});
3535

3636
// Configure console logging using the simpler, more compact format

samples/ScheduleWebApp/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"dotnetRunMessages": true,
1616
"environmentVariables": {
1717
"ASPNETCORE_ENVIRONMENT": "Development",
18-
"DURABLE_TASK_SCHEDULER_CONNECTION_STRING": "Endpoint=https://wbtestschedule01-g7fvgkfhe4ac.eastus2euap.durabletask.io;TaskHub=wbtestschedule01th01;Authentication=DefaultAzure"
18+
"DURABLE_TASK_SCHEDULER_CONNECTION_STRING": "<your-connection-string>"
1919
}
2020
}
2121
}

src/ScheduledTasks/Client/ScheduledTaskClient.cs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,10 @@ namespace Microsoft.DurableTask.ScheduledTasks;
1111
/// <summary>
1212
/// Client for managing scheduled tasks in a Durable Task application.
1313
/// </summary>
14-
public class ScheduledTaskClient : IScheduledTaskClient
14+
public class ScheduledTaskClient(DurableTaskClient durableTaskClient, ILogger logger) : IScheduledTaskClient
1515
{
16-
readonly DurableTaskClient durableTaskClient;
17-
readonly ILogger logger;
18-
19-
/// <summary>
20-
/// Initializes a new instance of the <see cref="ScheduledTaskClient"/> class.
21-
/// </summary>
22-
/// <param name="durableTaskClient">The Durable Task client to use for orchestration operations.</param>
23-
/// <param name="logger">logger.</param>
24-
public ScheduledTaskClient(DurableTaskClient durableTaskClient, ILogger logger)
25-
{
26-
this.durableTaskClient = Check.NotNull(durableTaskClient, nameof(durableTaskClient));
27-
this.logger = Check.NotNull(logger, nameof(logger));
28-
}
16+
readonly DurableTaskClient durableTaskClient = Check.NotNull(durableTaskClient, nameof(durableTaskClient));
17+
readonly ILogger logger = Check.NotNull(logger, nameof(logger));
2918

3019
/// <inheritdoc/>
3120
public async Task<ScheduleHandle> CreateScheduleAsync(ScheduleCreationOptions creationOptions, CancellationToken cancellation = default)

src/ScheduledTasks/Exception/ScheduleAlreadyExistException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Microsoft.DurableTask.ScheduledTasks;
66
/// <summary>
77
/// Exception thrown when attempting to create a schedule with an ID that already exists.
88
/// </summary>
9-
public class ScheduleAlreadyExistException : Exception
9+
public class ScheduleAlreadyExistException : InvalidOperationException
1010
{
1111
/// <summary>
1212
/// Initializes a new instance of the <see cref="ScheduleAlreadyExistException"/> class.

src/ScheduledTasks/Exception/ScheduleClientValidationException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Microsoft.DurableTask.ScheduledTasks;
66
/// <summary>
77
/// Exception thrown when client-side validation fails for schedule operations.
88
/// </summary>
9-
public class ScheduleClientValidationException : Exception
9+
public class ScheduleClientValidationException : InvalidOperationException
1010
{
1111
/// <summary>
1212
/// Initializes a new instance of the <see cref="ScheduleClientValidationException"/> class.

src/ScheduledTasks/Exception/ScheduleInvalidTransitionException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Microsoft.DurableTask.ScheduledTasks;
66
/// <summary>
77
/// Exception thrown when an invalid state transition is attempted on a schedule.
88
/// </summary>
9-
public class ScheduleInvalidTransitionException : Exception
9+
public class ScheduleInvalidTransitionException : InvalidOperationException
1010
{
1111
/// <summary>
1212
/// Initializes a new instance of the <see cref="ScheduleInvalidTransitionException"/> class.

src/ScheduledTasks/Exception/ScheduleNotFoundException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Microsoft.DurableTask.ScheduledTasks;
66
/// <summary>
77
/// Exception thrown when attempting to access a schedule that does not exist.
88
/// </summary>
9-
public class ScheduleNotFoundException : Exception
9+
public class ScheduleNotFoundException : InvalidOperationException
1010
{
1111
/// <summary>
1212
/// Initializes a new instance of the <see cref="ScheduleNotFoundException"/> class.

src/ScheduledTasks/Extension/DurableTaskClientBuilderExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ namespace Microsoft.DurableTask.ScheduledTasks;
1313
public static class DurableTaskClientBuilderExtensions
1414
{
1515
/// <summary>
16-
/// Enables scheduled task support for the client builder.
16+
/// Enables scheduled tasks support for the client builder.
1717
/// </summary>
1818
/// <param name="builder">The client builder to add scheduled task support to.</param>
1919
/// <returns>The original builder, for call chaining.</returns>
20-
public static IDurableTaskClientBuilder EnableScheduledTasksSupport(this IDurableTaskClientBuilder builder)
20+
public static IDurableTaskClientBuilder UseScheduledTasks(this IDurableTaskClientBuilder builder)
2121
{
2222
builder.Services.AddTransient<IScheduledTaskClient>(sp =>
2323
{

0 commit comments

Comments
 (0)