Miscellaneous changes for Notifications#212
Conversation
|
Sorry, I actually forgot to drop the now longer used |
ac6a525 to
3054594
Compare
|
I've fixed the linter errors and rephrased some of the doc blocks a bit. |
3054594 to
ec43989
Compare
|
Rebased. |
ec43989 to
cf8bd79
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the Go library APIs used by Icinga Notifications (and Icinga DB’s Notifications source) by evolving the Notifications Event model/validation, simplifying the plugin-facing request payload, and adding helper utilities for DB streaming and Redis stream cleanup.
Changes:
- Added richer
notifications/event.Eventflags (Muted,Incident,Close,Notify) plus aValidate()method and related helpers. - Simplified the channel plugin
Eventpayload and subject/message formatting by removingType/Usernameusage. - Introduced new helpers:
database.OnSuccessApplyAndSendToandredis.Client.XDelOnAllConsumersAck; removed the oldnotifications/event.Typeimplementation and tests.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| redis/client.go | Adds XDelOnAllConsumersAck helper to delete stream entries after all consumers ack. |
| notifications/plugin/plugin.go | Removes plugin-facing event Type/Username and simplifies subject/message formatting. |
| notifications/event/type.go | Removes old event.Type enum and JSON/SQL integration. |
| notifications/event/type_test.go | Removes tests for the deleted event.Type. |
| notifications/event/type_string.go | Removes generated String() mapping for the deleted event.Type. |
| notifications/event/event.go | Adds new Event flags/helpers and Validate() logic. |
| notifications/event/event_test.go | Adds tests for Validate() and updates JSON encoding expectations after model changes. |
| database/db.go | Adds OnSuccessApplyAndSendTo helper for transforming rows before streaming to a channel. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
cf8bd79 to
70214a1
Compare
0ff2450 to
e397215
Compare
This commit adds some new fields to the `Event` type and renames the existing `Mute` and `MuteReason` to `Muted` and `MutedReason` accordingly. Also, this commit moves some basic `Event` validations from Icinga Notifications that can be used from both the sources and Icinga Notifications to validate generated and receivent events.
This is similar to the existing `OnSuccessSendTo` one, but with an additional option to apply a custom function on the received row before streaming it to out channel.
e397215 to
c6b45e2
Compare
For the CI? The compatibility tests are still going to fail but rebased it anyway. |
This commit introduces the `XDelOnAllConsumersAck` helper function, which allows for the deletion of messages from a stream once they have been acknowledged by all consumers. This function is particularly useful in scenarios where 2 or more consumers need to xread from the same stream, and want to still ensure that messages are only deleted after all consumers have acknowledged them.
c6b45e2 to
5ed29e8
Compare
Umm, yes, I'm still not fully awake. Otherwise, the PR LGTM. Thanks. Due to the breaking API, I am going to approve it when I am finished with the other PRs. |
This adds the following three commits needed by the Icinga Notifications source implementation in Icinga DB and by Icinga Notifications daemon itself:
Eventtype and renames the existingMuteandMuteReasontoMutedandMutedReasonaccordingly. Also, this commit moves some basicEventvalidations (as described in Let sources affect incidents in multiple ways with a single event icinga-notifications#407) from Icinga Notifications that can be used from both the sources and Icinga Notifications to validate generated and receivent events.OnSuccessApplyAndSendTohelper function. It is similar to the existingOnSuccessSendToone, but with an additional option to apply a custom function on the received row before streaming it to out channel.Redis.XDelOnAllConsumersAckhelper function, which allows for the deletion of messages from a stream once they have been acknowledged by all consumers. This function is particularly useful in scenarios where 2 or more consumers need to xread from the same stream, and want to still ensure that messages are only deleted after all consumers have acknowledged them.refs Icinga/icingadb#1130