Add QueueDeleted event to IQueue<T> for queue deletion notifications#447
Merged
Add QueueDeleted event to IQueue<T> for queue deletion notifications#447
Conversation
Adds a QueueDeleted async event raised after a queue is deleted via DeleteQueueAsync. This enables behaviors and event handlers to react to queue deletion (e.g., cleanup, logging, cache invalidation). - Add QueueDeletedEventArgs<T> and QueueDeleted event to IQueue<T> - Implement OnQueueDeletedAsync in QueueBase with parallel invocation - Refactor DeleteQueueAsync into base class with DeleteQueueImplAsync pattern - Move trace logging from InMemoryQueue to QueueBase for all implementations - Wire QueueDeleted into QueueBehaviorBase for behavior support - Dispose QueueDeleted event in QueueBase.Dispose - Update queue documentation with QueueDeleted event and behavior examples Co-authored-by: Cursor <cursoragent@cursor.com>
ejsmith
approved these changes
Feb 6, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new queue-deletion lifecycle event so queue consumers/behaviors can react after a queue is deleted, and refactors deletion into QueueBase for consistent behavior across implementations.
Changes:
- Adds
QueueDeletedasync event toIQueue<T>and introducesQueueDeletedEventArgs<T>. - Refactors
DeleteQueueAsyncintoQueueBasevia a newDeleteQueueImplAsyncoverride point, and raisesQueueDeletedafter deletion. - Updates
QueueBehaviorBase<T>, docs, and in-memory queue tests to cover the new event.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Foundatio.Tests/Queue/InMemoryQueueTests.cs | Adds tests asserting QueueDeleted is raised and behaviors are invoked on delete. |
| src/Foundatio/Queues/QueueBehaviour.cs | Hooks QueueDeleted into QueueBehaviorBase<T>.Attach. |
| src/Foundatio/Queues/QueueBase.cs | Implements DeleteQueueAsync in base, adds QueueDeleted event + invocation + disposal. |
| src/Foundatio/Queues/InMemoryQueue.cs | Updates in-memory implementation to override DeleteQueueImplAsync and removes duplicate logging. |
| src/Foundatio/Queues/IQueue.cs | Extends IQueue<T> with QueueDeleted and adds the new event args type. |
| docs/guide/queues.md | Documents the new event and behavior override example. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
docs/guide/queues.md
Outdated
Comment on lines
419
to
422
| queue.QueueDeleted.AddHandler(async (sender, args) => | ||
| { | ||
| _logger.LogInformation("Queue deleted"); | ||
| }); |
There was a problem hiding this comment.
This example uses an async lambda with no await, which will produce a compiler warning in real code. Consider removing async (return Task.CompletedTask) or adding an awaited operation so the snippet is warning-free.
Remove async keyword from event handler lambdas that have no await, replacing them with synchronous lambdas that return Task.CompletedTask. Also fix Enqueuing handler to use args.Data instead of args.Entry.Value. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
Test plan
Made with Cursor