-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplequeue improvements: dead letters and backoff policy (#827)
## Motivation and Context (Why the change? What's the scenario?) When working with simplequeue locally, it's difficult to debug errors missing some better pipeline retry logic. ## High level description (Approach, Design) * Add poison message handling to SimpleQueue * Add backoff policy to SimpleQueue
- Loading branch information
Showing
6 changed files
with
348 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Microsoft.KernelMemory.Pipeline.Queue.DevTools; | ||
|
||
internal class Message | ||
{ | ||
[JsonPropertyName("id")] | ||
public string Id { get; set; } = string.Empty; | ||
|
||
[JsonPropertyName("content")] | ||
public string Content { get; set; } = string.Empty; | ||
|
||
[JsonPropertyName("deliveries")] | ||
public uint DequeueCount { get; set; } = 0; | ||
|
||
[JsonPropertyName("created")] | ||
public DateTimeOffset Created { get; set; } = DateTimeOffset.UtcNow; | ||
|
||
[JsonPropertyName("schedule")] | ||
public DateTimeOffset Schedule { get; set; } = DateTimeOffset.UtcNow; | ||
|
||
[JsonPropertyName("lock")] | ||
public DateTimeOffset LockedUntil { get; set; } = DateTimeOffset.MinValue; | ||
|
||
[JsonPropertyName("error")] | ||
public string LastError { get; set; } = string.Empty; | ||
|
||
public bool IsLocked() | ||
{ | ||
return this.LockedUntil > DateTimeOffset.UtcNow; | ||
} | ||
|
||
public bool IsTimeToRun() | ||
{ | ||
return this.Schedule <= DateTimeOffset.UtcNow; | ||
} | ||
|
||
public void RunIn(TimeSpan delay) | ||
{ | ||
this.Schedule = DateTimeOffset.UtcNow + delay; | ||
} | ||
|
||
public void Lock(int seconds) | ||
{ | ||
this.LockedUntil = DateTimeOffset.UtcNow + TimeSpan.FromSeconds(Math.Max(0, seconds)); | ||
} | ||
|
||
public void Unlock() | ||
{ | ||
this.LockedUntil = DateTimeOffset.MinValue; | ||
} | ||
} |
Oops, something went wrong.