Allow infra to listen to activity actively
This commit is contained in:
@@ -5,15 +5,19 @@ Command writes to the database.
|
||||
Members:
|
||||
|
||||
- `pool: SqlitePool` - a sqlite connection pool
|
||||
- `pub notify: broadcast::Sender<Activity>` - callers can subscribe via `command.notify.subscribe()`
|
||||
|
||||
Notes:
|
||||
|
||||
- All public write methods should be atomic
|
||||
- All writes should be accompanied by an activity log entry of `(tenant, activity_type, resource_type, resource_id)`
|
||||
- `insert_activity` builds and returns the `Activity` struct (using `chrono::Utc::now()` for `created_at`)
|
||||
- After each successful commit, sends the `Activity` on the broadcast channel
|
||||
|
||||
## `pub fn new(&self, pool: SqlitePool) -> Self`
|
||||
|
||||
- Assigns pool to self
|
||||
- Creates the broadcast channel
|
||||
|
||||
## `pub fn create_tenant(&self, tenant: &Tenant) -> Result<()>`
|
||||
|
||||
@@ -51,7 +55,7 @@ Notes:
|
||||
- Sets relay status to `inactive`, sets `sync_error`
|
||||
- Logs activity as `(fail_relay_sync, relay_id)`
|
||||
|
||||
## `pub fn mark_relay_synced(&self, relay_id: &str) -> Result<()>`
|
||||
## `pub fn complete_relay_sync(&self, relay_id: &str) -> Result<()>`
|
||||
|
||||
- Sets `synced = 1`, `status = 'active'`, clears `sync_error`
|
||||
- No activity log (called by infra after successful sync)
|
||||
- Logs activity as `(complete_relay_sync, relay_id)`
|
||||
|
||||
Reference in New Issue
Block a user