Skip to content

Miscellaneous changes for Notifications#212

Merged
oxzi merged 4 commits into
mainfrom
extend-notifications-event-type
Jun 30, 2026
Merged

Miscellaneous changes for Notifications#212
oxzi merged 4 commits into
mainfrom
extend-notifications-event-type

Conversation

@yhabteab

Copy link
Copy Markdown
Member

This adds the following three commits needed by the Icinga Notifications source implementation in Icinga DB and by Icinga Notifications daemon itself:

  • d3bfbd9 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 (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.
  • 1bdb4a5 This commit introduces a new OnSuccessApplyAndSendTo helper function. It 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.
  • 06c9e1b Introduces a new Redis.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.

refs Icinga/icingadb#1130

@yhabteab

Copy link
Copy Markdown
Member Author

Sorry, I actually forgot to drop the now longer used Event.Type and Event.Username fields.

@yhabteab

Copy link
Copy Markdown
Member Author

I've fixed the linter errors and rephrased some of the doc blocks a bit.

@nilmerg nilmerg moved this from Todo to In progress in Icinga Notifications 1.0 Jun 17, 2026
@yhabteab
yhabteab force-pushed the extend-notifications-event-type branch from 3054594 to ec43989 Compare June 23, 2026 13:29
@yhabteab

Copy link
Copy Markdown
Member Author

Rebased.

Comment thread notifications/event/event.go
@yhabteab
yhabteab force-pushed the extend-notifications-event-type branch from ec43989 to cf8bd79 Compare June 25, 2026 12:24
@yhabteab
yhabteab requested a review from Copilot June 25, 2026 12:25
Comment thread notifications/event/event.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Event flags (Muted, Incident, Close, Notify) plus a Validate() method and related helpers.
  • Simplified the channel plugin Event payload and subject/message formatting by removing Type/Username usage.
  • Introduced new helpers: database.OnSuccessApplyAndSendTo and redis.Client.XDelOnAllConsumersAck; removed the old notifications/event.Type implementation 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.

Comment thread redis/client.go
Comment thread notifications/event/event.go Outdated
Comment thread notifications/event/event_test.go Outdated
Comment thread notifications/event/event.go
Comment thread notifications/event/event_test.go Outdated
Comment thread notifications/event/event_test.go Outdated
Comment thread notifications/event/event_test.go Outdated
Comment thread database/db.go
@yhabteab
yhabteab force-pushed the extend-notifications-event-type branch from cf8bd79 to 70214a1 Compare June 25, 2026 13:19
@yhabteab
yhabteab requested a review from Copilot June 25, 2026 13:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comment thread notifications/plugin/plugin.go Outdated
Comment thread notifications/event/event.go
Comment thread redis/client.go
@yhabteab
yhabteab force-pushed the extend-notifications-event-type branch 3 times, most recently from 0ff2450 to e397215 Compare June 26, 2026 06:57

@oxzi oxzi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good except the one comment. My prior two comments were already addressed in the meantime :)


For the CI, please consider rebasing.

Comment thread notifications/event/event.go
yhabteab added 2 commits June 29, 2026 10:16
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.
@yhabteab
yhabteab force-pushed the extend-notifications-event-type branch from e397215 to c6b45e2 Compare June 29, 2026 08:16
@yhabteab

Copy link
Copy Markdown
Member Author

For the CI, please consider rebasing.

For the CI? The compatibility tests are still going to fail but rebased it anyway.

@yhabteab
yhabteab requested a review from oxzi June 29, 2026 08:19
yhabteab added 2 commits June 29, 2026 10:25
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.
@yhabteab
yhabteab force-pushed the extend-notifications-event-type branch from c6b45e2 to 5ed29e8 Compare June 29, 2026 08:26
@oxzi

oxzi commented Jun 29, 2026

Copy link
Copy Markdown
Member

For the CI, please consider rebasing.

For the CI? The compatibility tests are still going to fail but rebased it anyway.

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.

@oxzi oxzi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@oxzi
oxzi merged commit 15d47af into main Jun 30, 2026
16 of 18 checks passed
@oxzi
oxzi deleted the extend-notifications-event-type branch June 30, 2026 08:07
@github-project-automation github-project-automation Bot moved this from In progress to Done in Icinga Notifications 1.0 Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla/signed CLA is signed by all contributors of a PR

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants