@@ -9,25 +9,37 @@ namespace Microsoft.DurableTask.ScheduledTasks;
99public record ScheduleCreationOptions
1010{
1111 /// <summary>
12- /// The interval of the schedule .
12+ /// Initializes a new instance of the <see cref="ScheduleCreationOptions"/> class .
1313 /// </summary>
14- TimeSpan interval ;
14+ /// <param name="scheduleId">The ID of the schedule, or null to generate one.</param>
15+ /// <param name="orchestrationName">The name of the orchestration to schedule.</param>
16+ /// <param name="interval">The time interval between schedule executions. Must be at least 1 second and cannot be negative.</param>
17+ public ScheduleCreationOptions ( string scheduleId , string orchestrationName , TimeSpan interval )
18+ {
19+ this . ScheduleId = Check . NotNullOrEmpty ( scheduleId , nameof ( scheduleId ) ) ;
20+ this . OrchestrationName = Check . NotNullOrEmpty ( orchestrationName , nameof ( orchestrationName ) ) ;
21+ if ( interval <= TimeSpan . Zero )
22+ {
23+ throw new ArgumentException ( "Interval must be positive" , nameof ( interval ) ) ;
24+ }
25+
26+ if ( interval . TotalSeconds < 1 )
27+ {
28+ throw new ArgumentException ( "Interval must be at least 1 second" , nameof ( interval ) ) ;
29+ }
1530
16- string orchestrationName = string . Empty ;
31+ this . Interval = interval ;
32+ }
1733
1834 /// <summary>
1935 /// Gets the name of the orchestration function to schedule.
2036 /// </summary>
21- public string OrchestrationName
22- {
23- get => this . orchestrationName ;
24- init => this . orchestrationName = Check . NotNullOrEmpty ( value , nameof ( value ) ) ;
25- }
37+ public string OrchestrationName { get ; }
2638
2739 /// <summary>
28- /// Gets the ID of the schedule, if not provided, default to a new GUID .
40+ /// Gets the ID of the schedule.
2941 /// </summary>
30- public string ScheduleId { get ; init ; } ;
42+ public string ScheduleId { get ; }
3143
3244 /// <summary>
3345 /// Gets the input to the orchestration function.
@@ -40,36 +52,19 @@ public string OrchestrationName
4052 public string ? OrchestrationInstanceId { get ; init ; }
4153
4254 /// <summary>
43- /// Gets the start time of the schedule.
55+ /// Gets the start time of the schedule. If not provided, default to the current time.
4456 /// </summary>
4557 public DateTimeOffset ? StartAt { get ; init ; }
4658
4759 /// <summary>
48- /// Gets the end time of the schedule.
60+ /// Gets the end time of the schedule. If not provided, schedule will run indefinitely.
4961 /// </summary>
5062 public DateTimeOffset ? EndAt { get ; init ; }
5163
5264 /// <summary>
5365 /// Gets the interval of the schedule.
5466 /// </summary>
55- public TimeSpan Interval
56- {
57- get => this . interval ;
58- init
59- {
60- if ( value <= TimeSpan . Zero )
61- {
62- throw new ArgumentException ( "Interval must be positive" , nameof ( value ) ) ;
63- }
64-
65- if ( value . TotalSeconds < 1 )
66- {
67- throw new ArgumentException ( "Interval must be at least 1 second" , nameof ( value ) ) ;
68- }
69-
70- this . interval = value ;
71- }
72- }
67+ public TimeSpan Interval { get ; }
7368
7469 /// <summary>
7570 /// Gets a value indicating whether to start the schedule immediately if it is late. Default is false.
0 commit comments