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

34
docs/api/general.md generated
View File

@ -253,6 +253,40 @@ curl -X GET http://coder-server:8080/api/v2/deployment/config \
"stackdriver": "string"
},
"metrics_cache_refresh_interval": 0,
"notifications": {
"dispatch_timeout": 0,
"email": {
"from": "string",
"hello": "string",
"smarthost": {
"host": "string",
"port": "string"
}
},
"fetch_interval": 0,
"lease_count": 0,
"lease_period": 0,
"max_send_attempts": 0,
"method": "string",
"retry_interval": 0,
"sync_buffer_size": 0,
"sync_interval": 0,
"webhook": {
"endpoint": {
"forceQuery": true,
"fragment": "string",
"host": "string",
"omitHost": true,
"opaque": "string",
"path": "string",
"rawFragment": "string",
"rawPath": "string",
"rawQuery": "string",
"scheme": "string",
"user": {}
}
}
},
"oauth2": {
"github": {
"allow_everyone": true,

172
docs/api/schemas.md generated
View File

@ -1679,6 +1679,40 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o
"stackdriver": "string"
},
"metrics_cache_refresh_interval": 0,
"notifications": {
"dispatch_timeout": 0,
"email": {
"from": "string",
"hello": "string",
"smarthost": {
"host": "string",
"port": "string"
}
},
"fetch_interval": 0,
"lease_count": 0,
"lease_period": 0,
"max_send_attempts": 0,
"method": "string",
"retry_interval": 0,
"sync_buffer_size": 0,
"sync_interval": 0,
"webhook": {
"endpoint": {
"forceQuery": true,
"fragment": "string",
"host": "string",
"omitHost": true,
"opaque": "string",
"path": "string",
"rawFragment": "string",
"rawPath": "string",
"rawQuery": "string",
"scheme": "string",
"user": {}
}
}
},
"oauth2": {
"github": {
"allow_everyone": true,
@ -2052,6 +2086,40 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o
"stackdriver": "string"
},
"metrics_cache_refresh_interval": 0,
"notifications": {
"dispatch_timeout": 0,
"email": {
"from": "string",
"hello": "string",
"smarthost": {
"host": "string",
"port": "string"
}
},
"fetch_interval": 0,
"lease_count": 0,
"lease_period": 0,
"max_send_attempts": 0,
"method": "string",
"retry_interval": 0,
"sync_buffer_size": 0,
"sync_interval": 0,
"webhook": {
"endpoint": {
"forceQuery": true,
"fragment": "string",
"host": "string",
"omitHost": true,
"opaque": "string",
"path": "string",
"rawFragment": "string",
"rawPath": "string",
"rawQuery": "string",
"scheme": "string",
"user": {}
}
}
},
"oauth2": {
"github": {
"allow_everyone": true,
@ -2246,6 +2314,7 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o
| `job_hang_detector_interval` | integer | false | | |
| `logging` | [codersdk.LoggingConfig](#codersdkloggingconfig) | false | | |
| `metrics_cache_refresh_interval` | integer | false | | |
| `notifications` | [codersdk.NotificationsConfig](#codersdknotificationsconfig) | false | | |
| `oauth2` | [codersdk.OAuth2Config](#codersdkoauth2config) | false | | |
| `oidc` | [codersdk.OIDCConfig](#codersdkoidcconfig) | false | | |
| `pg_auth` | string | false | | |
@ -2368,6 +2437,7 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o
| `auto-fill-parameters` |
| `multi-organization` |
| `custom-roles` |
| `notifications` |
| `workspace-usage` |
## codersdk.ExternalAuth
@ -2976,6 +3046,108 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o
| `id` | string | true | | |
| `username` | string | true | | |
## codersdk.NotificationsConfig
```json
{
"dispatch_timeout": 0,
"email": {
"from": "string",
"hello": "string",
"smarthost": {
"host": "string",
"port": "string"
}
},
"fetch_interval": 0,
"lease_count": 0,
"lease_period": 0,
"max_send_attempts": 0,
"method": "string",
"retry_interval": 0,
"sync_buffer_size": 0,
"sync_interval": 0,
"webhook": {
"endpoint": {
"forceQuery": true,
"fragment": "string",
"host": "string",
"omitHost": true,
"opaque": "string",
"path": "string",
"rawFragment": "string",
"rawPath": "string",
"rawQuery": "string",
"scheme": "string",
"user": {}
}
}
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
| ------------------- | -------------------------------------------------------------------------- | -------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `dispatch_timeout` | integer | false | | How long to wait while a notification is being sent before giving up. |
| `email` | [codersdk.NotificationsEmailConfig](#codersdknotificationsemailconfig) | false | | Email settings. |
| `fetch_interval` | integer | false | | How often to query the database for queued notifications. |
| `lease_count` | integer | false | | How many notifications a notifier should lease per fetch interval. |
| `lease_period` | integer | false | | How long a notifier should lease a message. This is effectively how long a notification is 'owned' by a notifier, and once this period expires it will be available for lease by another notifier. Leasing is important in order for multiple running notifiers to not pick the same messages to deliver concurrently. This lease period will only expire if a notifier shuts down ungracefully; a dispatch of the notification releases the lease. |
| `max_send_attempts` | integer | false | | The upper limit of attempts to send a notification. |
| `method` | string | false | | Which delivery method to use (available options: 'smtp', 'webhook'). |
| `retry_interval` | integer | false | | The minimum time between retries. |
| `sync_buffer_size` | integer | false | | The notifications system buffers message updates in memory to ease pressure on the database. This option controls how many updates are kept in memory. The lower this value the lower the change of state inconsistency in a non-graceful shutdown - but it also increases load on the database. It is recommended to keep this option at its default value. |
| `sync_interval` | integer | false | | The notifications system buffers message updates in memory to ease pressure on the database. This option controls how often it synchronizes its state with the database. The shorter this value the lower the change of state inconsistency in a non-graceful shutdown - but it also increases load on the database. It is recommended to keep this option at its default value. |
| `webhook` | [codersdk.NotificationsWebhookConfig](#codersdknotificationswebhookconfig) | false | | Webhook settings. |
## codersdk.NotificationsEmailConfig
```json
{
"from": "string",
"hello": "string",
"smarthost": {
"host": "string",
"port": "string"
}
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
| ----------- | ------------------------------------ | -------- | ------------ | --------------------------------------------------------------------- |
| `from` | string | false | | The sender's address. |
| `hello` | string | false | | The hostname identifying the SMTP server. |
| `smarthost` | [serpent.HostPort](#serpenthostport) | false | | The intermediary SMTP host through which emails are sent (host:port). |
## codersdk.NotificationsWebhookConfig
```json
{
"endpoint": {
"forceQuery": true,
"fragment": "string",
"host": "string",
"omitHost": true,
"opaque": "string",
"path": "string",
"rawFragment": "string",
"rawPath": "string",
"rawQuery": "string",
"scheme": "string",
"user": {}
}
}
```
### Properties
| Name | Type | Required | Restrictions | Description |
| ---------- | -------------------------- | -------- | ------------ | -------------------------------------------------------------------- |
| `endpoint` | [serpent.URL](#serpenturl) | false | | The URL to which the payload will be sent with an HTTP POST request. |
## codersdk.OAuth2AppEndpoints
```json

75
docs/cli/server.md generated
View File

@ -1194,3 +1194,78 @@ Refresh interval for healthchecks.
| Default | <code>15ms</code> |
The threshold for the database health check. If the median latency of the database exceeds this threshold over 5 attempts, the database is considered unhealthy. The default value is 15ms.
### --notifications-method
| | |
| ----------- | ---------------------------------------- |
| Type | <code>string</code> |
| Environment | <code>$CODER_NOTIFICATIONS_METHOD</code> |
| YAML | <code>notifications.method</code> |
| Default | <code>smtp</code> |
Which delivery method to use (available options: 'smtp', 'webhook').
### --notifications-dispatch-timeout
| | |
| ----------- | -------------------------------------------------- |
| Type | <code>duration</code> |
| Environment | <code>$CODER_NOTIFICATIONS_DISPATCH_TIMEOUT</code> |
| YAML | <code>notifications.dispatch-timeout</code> |
| Default | <code>1m0s</code> |
How long to wait while a notification is being sent before giving up.
### --notifications-email-from
| | |
| ----------- | -------------------------------------------- |
| Type | <code>string</code> |
| Environment | <code>$CODER_NOTIFICATIONS_EMAIL_FROM</code> |
| YAML | <code>notifications.email.from</code> |
The sender's address to use.
### --notifications-email-smarthost
| | |
| ----------- | ------------------------------------------------- |
| Type | <code>host:port</code> |
| Environment | <code>$CODER_NOTIFICATIONS_EMAIL_SMARTHOST</code> |
| YAML | <code>notifications.email.smarthost</code> |
| Default | <code>localhost:587</code> |
The intermediary SMTP host through which emails are sent.
### --notifications-email-hello
| | |
| ----------- | --------------------------------------------- |
| Type | <code>string</code> |
| Environment | <code>$CODER_NOTIFICATIONS_EMAIL_HELLO</code> |
| YAML | <code>notifications.email.hello</code> |
| Default | <code>localhost</code> |
The hostname identifying the SMTP server.
### --notifications-webhook-endpoint
| | |
| ----------- | -------------------------------------------------- |
| Type | <code>url</code> |
| Environment | <code>$CODER_NOTIFICATIONS_WEBHOOK_ENDPOINT</code> |
| YAML | <code>notifications.webhook.hello</code> |
The endpoint to which to send webhooks.
### --notifications-max-send-attempts
| | |
| ----------- | --------------------------------------------------- |
| Type | <code>int</code> |
| Environment | <code>$CODER_NOTIFICATIONS_MAX_SEND_ATTEMPTS</code> |
| YAML | <code>notifications.max-send-attempts</code> |
| Default | <code>5</code> |
The upper limit of attempts to send a notification.