diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-09-27 23:03:46 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-09-28 01:00:12 -0400 |
| commit | 60b711c844f8624348d5d1dac3a625532a8e2a82 (patch) | |
| tree | a667cfa3833046425a87ec03c700d6124af70e4e /src/repo/channel.rs | |
| parent | 08c3a6e77a3f61ffc9643a5e1f840df9078d0b36 (diff) | |
Delete expired messages out of band.
Trying to reliably do expiry mid-request was causing some anomalies:
* Creating a channel with a dup name would fail, then succeed after listing channels.
It was very hard to reason about which operations needed to trigger expiry, to fix this "correctly," so now expiry runs on every request.
Diffstat (limited to 'src/repo/channel.rs')
| -rw-r--r-- | src/repo/channel.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/repo/channel.rs b/src/repo/channel.rs index e85b898..6514426 100644 --- a/src/repo/channel.rs +++ b/src/repo/channel.rs @@ -2,7 +2,7 @@ use std::fmt; use sqlx::{sqlite::Sqlite, SqliteConnection, Transaction}; -use crate::{clock::DateTime, id::Id as BaseId}; +use crate::{clock::DateTime, events::types::Sequence, id::Id as BaseId}; pub trait Provider { fn channels(&mut self) -> Channels; @@ -31,13 +31,14 @@ impl<'c> Channels<'c> { created_at: &DateTime, ) -> Result<Channel, sqlx::Error> { let id = Id::generate(); + let sequence = Sequence::default(); let channel = sqlx::query_as!( Channel, r#" insert - into channel (id, name, created_at) - values ($1, $2, $3) + into channel (id, name, created_at, last_sequence) + values ($1, $2, $3, $4) returning id as "id: Id", name, @@ -46,6 +47,7 @@ impl<'c> Channels<'c> { id, name, created_at, + sequence, ) .fetch_one(&mut *self.0) .await?; |
