feat: implement thin vertical slice of system-generated notifications (#13537)

This commit is contained in:
Danny Kopping
2024-07-08 15:38:50 +02:00
committed by GitHub
parent 10aa32ca08
commit bdd2caf95d
51 changed files with 3686 additions and 50 deletions

101
coderd/apidoc/docs.go generated
View File

@ -9200,6 +9200,9 @@ const docTemplate = `{
"metrics_cache_refresh_interval": {
"type": "integer"
},
"notifications": {
"$ref": "#/definitions/codersdk.NotificationsConfig"
},
"oauth2": {
"$ref": "#/definitions/codersdk.OAuth2Config"
},
@ -9377,20 +9380,23 @@ const docTemplate = `{
"auto-fill-parameters",
"multi-organization",
"custom-roles",
"notifications",
"workspace-usage"
],
"x-enum-comments": {
"ExperimentAutoFillParameters": "This should not be taken out of experiments until we have redesigned the feature.",
"ExperimentCustomRoles": "Allows creating runtime custom roles",
"ExperimentCustomRoles": "Allows creating runtime custom roles.",
"ExperimentExample": "This isn't used for anything.",
"ExperimentMultiOrganization": "Requires organization context for interactions, default org is assumed.",
"ExperimentWorkspaceUsage": "Enables the new workspace usage tracking"
"ExperimentNotifications": "Sends notifications via SMTP and webhooks following certain events.",
"ExperimentWorkspaceUsage": "Enables the new workspace usage tracking."
},
"x-enum-varnames": [
"ExperimentExample",
"ExperimentAutoFillParameters",
"ExperimentMultiOrganization",
"ExperimentCustomRoles",
"ExperimentNotifications",
"ExperimentWorkspaceUsage"
]
},
@ -9925,6 +9931,97 @@ const docTemplate = `{
}
}
},
"codersdk.NotificationsConfig": {
"type": "object",
"properties": {
"dispatch_timeout": {
"description": "How long to wait while a notification is being sent before giving up.",
"type": "integer"
},
"email": {
"description": "SMTP settings.",
"allOf": [
{
"$ref": "#/definitions/codersdk.NotificationsEmailConfig"
}
]
},
"fetch_interval": {
"description": "How often to query the database for queued notifications.",
"type": "integer"
},
"lease_count": {
"description": "How many notifications a notifier should lease per fetch interval.",
"type": "integer"
},
"lease_period": {
"description": "How long a notifier should lease a message. This is effectively how long a notification is 'owned'\nby a notifier, and once this period expires it will be available for lease by another notifier. Leasing\nis important in order for multiple running notifiers to not pick the same messages to deliver concurrently.\nThis lease period will only expire if a notifier shuts down ungracefully; a dispatch of the notification\nreleases the lease.",
"type": "integer"
},
"max_send_attempts": {
"description": "The upper limit of attempts to send a notification.",
"type": "integer"
},
"method": {
"description": "Which delivery method to use (available options: 'smtp', 'webhook').",
"type": "string"
},
"retry_interval": {
"description": "The minimum time between retries.",
"type": "integer"
},
"sync_buffer_size": {
"description": "The notifications system buffers message updates in memory to ease pressure on the database.\nThis option controls how many updates are kept in memory. The lower this value the\nlower the change of state inconsistency in a non-graceful shutdown - but it also increases load on the\ndatabase. It is recommended to keep this option at its default value.",
"type": "integer"
},
"sync_interval": {
"description": "The notifications system buffers message updates in memory to ease pressure on the database.\nThis option controls how often it synchronizes its state with the database. The shorter this value the\nlower the change of state inconsistency in a non-graceful shutdown - but it also increases load on the\ndatabase. It is recommended to keep this option at its default value.",
"type": "integer"
},
"webhook": {
"description": "Webhook settings.",
"allOf": [
{
"$ref": "#/definitions/codersdk.NotificationsWebhookConfig"
}
]
}
}
},
"codersdk.NotificationsEmailConfig": {
"type": "object",
"properties": {
"from": {
"description": "The sender's address.",
"type": "string"
},
"hello": {
"description": "The hostname identifying the SMTP server.",
"type": "string"
},
"smarthost": {
"description": "The intermediary SMTP host through which emails are sent (host:port).",
"allOf": [
{
"$ref": "#/definitions/serpent.HostPort"
}
]
}
}
},
"codersdk.NotificationsWebhookConfig": {
"type": "object",
"properties": {
"endpoint": {
"description": "The URL to which the payload will be sent with an HTTP POST request.",
"allOf": [
{
"$ref": "#/definitions/serpent.URL"
}
]
}
}
},
"codersdk.OAuth2AppEndpoints": {
"type": "object",
"properties": {