-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from clickviewapp/QueueHostedService-logscope
Add LogScope to QueueHostedService to add the message id
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace ClickView.GoodStuff.Hosting.Queue; | ||
|
||
using System.Collections; | ||
using Queues.RabbitMq; | ||
|
||
internal class MessageContextScope<T>(MessageContext<T> context) : IReadOnlyList<KeyValuePair<string, object>> | ||
{ | ||
public IEnumerator<KeyValuePair<string, object>> GetEnumerator() | ||
{ | ||
for (var i = 0; i < Count; ++i) | ||
{ | ||
yield return this[i]; | ||
} | ||
} | ||
|
||
IEnumerator IEnumerable.GetEnumerator() | ||
{ | ||
return GetEnumerator(); | ||
} | ||
|
||
public int Count => 1; | ||
|
||
public KeyValuePair<string, object> this[int index] => index switch | ||
{ | ||
0 => new KeyValuePair<string, object>("MessageId", context.Id), | ||
_ => throw new IndexOutOfRangeException(nameof(index)), | ||
}; | ||
} |
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