22using System . Collections . Generic ;
33using System . Linq ;
44using System . Threading ;
5+ using System . Threading . Tasks ;
56using Temporalio . Api . WorkflowService . V1 ;
67using Temporalio . Common ;
78using Temporalio . Converters ;
@@ -16,16 +17,11 @@ public class ScheduleDescription
1617 private readonly Lazy < IReadOnlyDictionary < string , IEncodedRawValue > > memo ;
1718 private readonly Lazy < SearchAttributeCollection > searchAttributes ;
1819
19- /// <summary>
20- /// Initializes a new instance of the <see cref="ScheduleDescription"/> class.
21- /// </summary>
22- /// <param name="id">Workflow ID.</param>
23- /// <param name="rawDescription">Raw proto description.</param>
24- /// <param name="dataConverter">Data converter.</param>
25- internal ScheduleDescription (
26- string id , DescribeScheduleResponse rawDescription , DataConverter dataConverter )
20+ private ScheduleDescription (
21+ string id , Schedule schedule , DescribeScheduleResponse rawDescription , DataConverter dataConverter )
2722 {
2823 Id = id ;
24+ Schedule = schedule ;
2925 RawDescription = rawDescription ;
3026 // Search attribute conversion is cheap so it doesn't need to lock on publication. But
3127 // memo conversion may use remote codec so it should only ever be created once lazily.
@@ -39,7 +35,6 @@ internal ScheduleDescription(
3935 SearchAttributeCollection . Empty :
4036 SearchAttributeCollection . FromProto ( rawDescription . SearchAttributes ) ,
4137 LazyThreadSafetyMode . PublicationOnly ) ;
42- Schedule = Schedule . FromProto ( rawDescription . Schedule , dataConverter ) ;
4338 Info = ScheduleInfo . FromProto ( rawDescription . Info ) ;
4439 }
4540
@@ -77,5 +72,20 @@ internal ScheduleDescription(
7772 /// Gets the raw proto description.
7873 /// </summary>
7974 internal DescribeScheduleResponse RawDescription { get ; private init ; }
75+
76+ /// <summary>
77+ /// Convert from proto.
78+ /// </summary>
79+ /// <param name="id">ID.</param>
80+ /// <param name="rawDescription">Proto.</param>
81+ /// <param name="dataConverter">Converter.</param>
82+ /// <returns>Converted value.</returns>
83+ internal static async Task < ScheduleDescription > FromProtoAsync (
84+ string id , DescribeScheduleResponse rawDescription , DataConverter dataConverter ) =>
85+ new (
86+ id ,
87+ await Schedule . FromProtoAsync ( rawDescription . Schedule , dataConverter ) . ConfigureAwait ( false ) ,
88+ rawDescription ,
89+ dataConverter ) ;
8090 }
8191}
0 commit comments