Skip to content

Commit

Permalink
feat: publish events on insertion of unhealthy & warning config items
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Sep 13, 2024
1 parent a724d00 commit 4b8f34c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion views/007_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ RETURNS TRIGGER AS $$
DECLARE
event_name TEXT;
BEGIN
IF TG_OP = 'INSERT' THEN
IF NEW.health NOT IN ('warning', 'unhealthy') THEN
RETURN NUll;
END IF;
END IF;

IF OLD.health = NEW.health OR (OLD.health IS NULL AND NEW.health IS NULL) THEN
RETURN NULL;
END IF;
Expand All @@ -185,7 +191,7 @@ END
$$ LANGUAGE plpgsql;

CREATE OR REPLACE TRIGGER config_health_event_enqueue
AFTER UPDATE ON config_items
AFTER INSERT OR UPDATE ON config_items
FOR EACH ROW
EXECUTE PROCEDURE insert_config_health_updates_in_event_queue();

Expand Down

0 comments on commit 4b8f34c

Please sign in to comment.