-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configuration + Webhooks : PG Notify/Trigger (#361)
* updated implementation to use configuration cache * changed log level for cache to debug * removed extra export fr cache * updated config end-points to pull latest & return latest in response * removed extra logging for webhooks * cleaned webhooks cache debug logs
- Loading branch information
Showing
43 changed files
with
510 additions
and
116 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
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
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
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
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
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
65 changes: 65 additions & 0 deletions
65
src/prisma/migrations/20231226100100_webhook_config_triggers/migration.sql
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,65 @@ | ||
-- Configuration Triggers | ||
CREATE OR REPLACE FUNCTION notify_configuration_insert() | ||
RETURNS TRIGGER | ||
LANGUAGE plpgsql | ||
AS $function$ | ||
BEGIN | ||
PERFORM pg_notify('new_configuration_data', row_to_json(NEW)::text); | ||
RETURN NEW; | ||
END; | ||
$function$; | ||
|
||
CREATE OR REPLACE FUNCTION notify_configuration_update() | ||
RETURNS TRIGGER | ||
LANGUAGE plpgsql | ||
AS $function$ | ||
BEGIN | ||
PERFORM pg_notify('updated_configuration_data', json_build_object( | ||
'id', NEW.id | ||
)::text); | ||
RETURN NEW; | ||
END; | ||
$function$; | ||
|
||
CREATE OR REPLACE TRIGGER configuration_insert_trigger | ||
AFTER INSERT ON configuration | ||
FOR EACH ROW | ||
EXECUTE FUNCTION notify_configuration_insert(); | ||
|
||
CREATE OR REPLACE TRIGGER configuration_update_trigger | ||
AFTER UPDATE ON configuration | ||
FOR EACH ROW | ||
EXECUTE FUNCTION notify_configuration_update(); | ||
|
||
-- Webhooks Triggers | ||
CREATE OR REPLACE FUNCTION notify_webhooks_insert() | ||
RETURNS TRIGGER | ||
LANGUAGE plpgsql | ||
AS $function$ | ||
BEGIN | ||
PERFORM pg_notify('new_webhook_data', row_to_json(NEW)::text); | ||
RETURN NEW; | ||
END; | ||
$function$; | ||
|
||
CREATE OR REPLACE FUNCTION notify_webhooks_update() | ||
RETURNS TRIGGER | ||
LANGUAGE plpgsql | ||
AS $function$ | ||
BEGIN | ||
PERFORM pg_notify('updated_webhook_data', json_build_object( | ||
'id', NEW.id | ||
)::text); | ||
RETURN NEW; | ||
END; | ||
$function$; | ||
|
||
CREATE OR REPLACE TRIGGER webhooks_insert_trigger | ||
AFTER INSERT ON webhooks | ||
FOR EACH ROW | ||
EXECUTE FUNCTION notify_webhooks_insert(); | ||
|
||
CREATE OR REPLACE TRIGGER webhooks_update_trigger | ||
AFTER UPDATE ON webhooks | ||
FOR EACH ROW | ||
EXECUTE FUNCTION notify_webhooks_update(); |
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.