You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whilst this isn't difficult to do, it does feel a bit janky.
Proposed solution
We move to file-based notification templates. These could be embedded in the Go binary with the embed package.
An example
Given the following notification template:
INSERT INTO notification_templates
(id, name, title_template, body_template, "group", actions)
VALUES (
'a9d027b4-ac49-4fb1-9f6d-45af15f64e7a',
'Workspace Out Of Memory',
E'Your workspace "{{.Labels.workspace}}" is low on memory',
E'Hi {{.UserName}},\n\n'||
E'Your workspace **{{.Labels.workspace}}** has reached the memory usage threshold set at **{{.Labels.threshold}}**.',
'Workspace Events',
'[ { "label": "View workspace", "url": "{{base_url}}/@{{.UserUsername}}/{{.Labels.workspace}}" } ]'::jsonb
);
We could store this in a TOML file with the design:
id = "a9d027b4-ac49-4fb1-9f6d-45af15f64e7a"name = "Workspace Out Of Memory"group = "Workspace Events"title_template = 'Your workspace "{{.Labels.workspace}}" is low on memory'body_template = '''Hi {{.UserName}},Your workspace **{{.Labels.workspace}}** has reached the memory usage threshold set at **{{.Labels.threshold}}*.'''
[[actions]]
label = "View workspace"url = '{{base_url}}/@{{.UserUsername}}/{{.Labels.workspace}}'
Any future changes to this notification wouldn't require creating a new migration where you need to ensure the down migration goes back to the correct state.
Custom Notifications
The original database oriented design was indented to allow making it easy for supporting the use-case of custom notifications. This solution could support that by having a table in the database that stores custom notifications templates.
The text was updated successfully, but these errors were encountered:
Problem
Currently we store our notification templates in the database.
If we want to make small changes to our notifications we have to make migrations like the following:
Whilst this isn't difficult to do, it does feel a bit janky.
Proposed solution
We move to file-based notification templates. These could be embedded in the Go binary with the embed package.
An example
Given the following notification template:
We could store this in a TOML file with the design:
Any future changes to this notification wouldn't require creating a new migration where you need to ensure the down migration goes back to the correct state.
Custom Notifications
The original database oriented design was indented to allow making it easy for supporting the use-case of custom notifications. This solution could support that by having a table in the database that stores custom notifications templates.
The text was updated successfully, but these errors were encountered: