Skip to content

Commit

Permalink
[JobRouter] Fix TTL
Browse files Browse the repository at this point in the history
  • Loading branch information
williamzhao87 committed Jul 17, 2023
1 parent a5d3211 commit 4a76c65
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,7 @@ public PassThroughQueueSelectorAttachment(string key, Azure.Communication.JobRou
public partial class PassThroughWorkerSelectorAttachment : Azure.Communication.JobRouter.WorkerSelectorAttachment
{
public PassThroughWorkerSelectorAttachment(string key, Azure.Communication.JobRouter.LabelOperator labelOperator) { }
public PassThroughWorkerSelectorAttachment(string key, Azure.Communication.JobRouter.LabelOperator labelOperator, System.TimeSpan? ttl = default(System.TimeSpan?)) { }
public double? ExpiresAfterSeconds { get { throw null; } set { } }
public PassThroughWorkerSelectorAttachment(string key, Azure.Communication.JobRouter.LabelOperator labelOperator, System.TimeSpan? expiresAfter = default(System.TimeSpan?)) { }
public string Key { get { throw null; } set { } }
public Azure.Communication.JobRouter.LabelOperator LabelOperator { get { throw null; } set { } }
}
Expand Down Expand Up @@ -523,12 +522,11 @@ public partial class RouterWorkerSelector
{
public RouterWorkerSelector(string key, Azure.Communication.JobRouter.LabelOperator labelOperator, Azure.Communication.JobRouter.LabelValue value) { }
public bool? Expedite { get { throw null; } set { } }
public double? ExpiresAfterSeconds { get { throw null; } set { } }
public System.TimeSpan? ExpiresAfter { get { throw null; } set { } }
public System.DateTimeOffset? ExpiresAt { get { throw null; } }
public string Key { get { throw null; } set { } }
public Azure.Communication.JobRouter.LabelOperator LabelOperator { get { throw null; } set { } }
public Azure.Communication.JobRouter.Models.RouterWorkerSelectorStatus? Status { get { throw null; } }
public System.TimeSpan? Ttl { get { throw null; } set { } }
public Azure.Communication.JobRouter.LabelValue Value { get { throw null; } set { } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ public partial class PassThroughWorkerSelectorAttachment
/// <summary> Initializes a new instance of PassThroughWorkerSelectorAttachment. </summary>
/// <param name="key"> The label key to query against. </param>
/// <param name="labelOperator"> Describes how the value of the label is compared to the value pass through. </param>
/// <param name="ttl"> Describes how long the attached label selector is valid. </param>
/// <param name="expiresAfter"> Describes how long the attached label selector is valid. </param>
/// <exception cref="ArgumentNullException"> <paramref name="key"/> is null. </exception>
public PassThroughWorkerSelectorAttachment(string key, LabelOperator labelOperator, TimeSpan? ttl = default)
: this(null, key, labelOperator, ttl?.TotalSeconds)
public PassThroughWorkerSelectorAttachment(string key, LabelOperator labelOperator, TimeSpan? expiresAfter = default)
: this(null, key, labelOperator, expiresAfter?.TotalSeconds)
{
Argument.AssertNotNullOrWhiteSpace(key, nameof(key));
}

/// <summary> Describes how long the attached label selector is valid in seconds. </summary>
internal TimeSpan? Ttl { get; set; }
internal TimeSpan? ExpiresAfter { get; set; }

[CodeGenMember("TtlSeconds")]
internal double? _ttlSeconds {
[CodeGenMember("ExpiresAfterSeconds")]
internal double? _expiresAfterSeconds {
get
{
return Ttl?.TotalSeconds is null or 0 ? null : Ttl?.TotalSeconds;
return ExpiresAfter?.TotalSeconds is null or 0 ? null : ExpiresAfter?.TotalSeconds;
}
set
{
Ttl = value != null ? TimeSpan.FromSeconds(value.Value) : null;
ExpiresAfter = value != null ? TimeSpan.FromSeconds(value.Value) : null;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ internal IDictionary<string, string> _notes
get
{
return Notes != null && Notes.Count != 0
? Notes?.ToDictionary(x => (x.AddedAtUtc ?? DateTimeOffset.UtcNow)
? Notes?.ToDictionary(x => (x.AddedAt ?? DateTimeOffset.UtcNow)
.ToUniversalTime().ToString("O", CultureInfo.InvariantCulture), x => x.Message)
: new ChangeTrackingDictionary<string, string>();
}
Expand All @@ -118,7 +118,7 @@ internal IDictionary<string, string> _notes
{
Notes.Add(new RouterJobNote
{
AddedAtUtc = DateTimeOffsetParser.ParseAndGetDateTimeOffset(note.Key),
AddedAt = DateTimeOffsetParser.ParseAndGetDateTimeOffset(note.Key),
Message = note.Value
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class RouterJobNote
public string Message { get; set; }

/// <summary>
/// The time at which the note was added. If not provided, will default to the current time.
/// The time at which the note was added in UTC. If not provided, will default to the current time.
/// </summary>
public DateTimeOffset? AddedAtUtc { get; set; }
public DateTimeOffset? AddedAt { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ namespace Azure.Communication.JobRouter
public partial class RouterWorkerSelector
{
/// <summary> Describes how long this label selector is valid in seconds. </summary>
public TimeSpan? Ttl { get; set; }
public TimeSpan? ExpiresAfter { get; set; }

[CodeGenMember("TtlSeconds")]
internal double? _ttlSeconds {
[CodeGenMember("ExpiresAfterSeconds")]
internal double? _expiresAfterSeconds {
get
{
return Ttl?.TotalSeconds is null or 0 ? null : Ttl?.TotalSeconds;
return ExpiresAfter?.TotalSeconds is null or 0 ? null : ExpiresAfter?.TotalSeconds;
}
set
{
Ttl = value != null ? TimeSpan.FromSeconds(value.Value) : null;
ExpiresAfter = value != null ? TimeSpan.FromSeconds(value.Value) : null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public async Task UpdateJobWithNotesWorksCorrectly()
{
Notes =
{
new RouterJobNote { AddedAtUtc = updateNoteTimeStamp, Message = "Fake notes attached to job with update" }
new RouterJobNote { AddedAt = updateNoteTimeStamp, Message = "Fake notes attached to job with update" }
}
});
}
Expand All @@ -62,7 +62,7 @@ public async Task UpdateJobWithNotesWorksCorrectly()
{
Notes =
{
new RouterJobNote { AddedAtUtc = updateNoteTimeStamp, Message = "Fake notes attached to job with update" }
new RouterJobNote { AddedAt = updateNoteTimeStamp, Message = "Fake notes attached to job with update" }
}
});
}
Expand Down

0 comments on commit 4a76c65

Please sign in to comment.