Skip to main content

Module delayed_events

Module delayed_events 

Source
Expand description

Delayed events (MSC4140): events scheduled now and sent later.

A scheduled event is three rows written in one batch: its record, a due-time index entry, and an owner index entry. The worker sends each event when it falls due through the ordinary append path, so events overdue at startup go out on its first pass. Whatever the outcome, one batch then replaces the three rows with a finalised record, and a crash between the two steps can send an event twice. Finalised records are kept for about a week, or less once their column reaches its size cap.

Re-exportsΒ§

use std::collections::BTreeMap; πŸ”’
use std::pin::pin; πŸ”’
use std::sync::Arc; πŸ”’
use std::time::Duration; πŸ”’
use async_trait::async_trait; πŸ”’
use futures::Stream; πŸ”’
use futures::StreamExt; πŸ”’
use futures::TryFutureExt; πŸ”’
use futures::future::Either; πŸ”’
use futures::future::select; πŸ”’
use futures::stream::unfold; πŸ”’
use http::StatusCode; πŸ”’
use ruma::EventId; πŸ”’
use ruma::MilliSecondsSinceUnixEpoch; πŸ”’
use ruma::OwnedEventId; πŸ”’
use ruma::OwnedRoomId; πŸ”’
use ruma::OwnedUserId; πŸ”’
use ruma::UserId; πŸ”’
use ruma::api::client::delayed_events::get_delayed_event::v1::Finalized; πŸ”’
use ruma::api::error::ErrorKind; πŸ”’
use ruma::api::error::LimitExceededErrorData; πŸ”’
use ruma::api::error::RetryAfter; πŸ”’
use ruma::api::error::StandardErrorBody; πŸ”’
use ruma::events::TimelineEventType; πŸ”’
use serde::Deserialize; πŸ”’
use serde::Deserialize; πŸ”’
use serde::Serialize; πŸ”’
use serde::Serialize; πŸ”’
use tokio::sync::Notify; πŸ”’
use tokio::time::timeout; πŸ”’
use tuwunel_core::Err; πŸ”’
use tuwunel_core::Error; πŸ”’
use tuwunel_core::Result; πŸ”’
use tuwunel_core::debug_warn; πŸ”’
use tuwunel_core::err; πŸ”’
use tuwunel_core::error; πŸ”’
use tuwunel_core::error; πŸ”’
use tuwunel_core::implement; πŸ”’
use tuwunel_core::result::NotFound; πŸ”’
use tuwunel_core::smallstr::SmallString; πŸ”’
use tuwunel_core::utils::MutexMap; πŸ”’
use tuwunel_core::utils::MutexMapGuard; πŸ”’
use tuwunel_core::utils::rand::string_array; πŸ”’
use tuwunel_core::utils::stream::BroadbandExt; πŸ”’
use tuwunel_core::utils::stream::ReadyExt; πŸ”’
use tuwunel_core::utils::stream::TryIgnore; πŸ”’
use tuwunel_core::utils::stream::WidebandExt; πŸ”’
use tuwunel_core::utils::stream::automatic_width; πŸ”’
use tuwunel_core::utils::time::now_millis; πŸ”’
use tuwunel_core::warn; πŸ”’
use tuwunel_database::Deserialized; πŸ”’
use tuwunel_database::Ignore; πŸ”’
use tuwunel_database::Interfix; πŸ”’
use tuwunel_database::Json; πŸ”’
use tuwunel_database::Map; πŸ”’
use tuwunel_matrix::StateKey; πŸ”’
use tuwunel_matrix::pdu::Content; πŸ”’
use tuwunel_matrix::pdu::DELAY_ID; πŸ”’
use tuwunel_matrix::pdu::PduBuilder; πŸ”’
use crate::service::make_name; πŸ”’
use crate::transaction_ids::RoomScope; πŸ”’
use crate::transaction_ids::RoomTxn; πŸ”’

StructsΒ§

Data πŸ”’
Event
A delayed event as stored, scheduled or finalised, and as reported to its owner.
Limits
The limits a client is told about and held to.
Service
Schedules delayed events and sends them when they fall due.

ConstantsΒ§

DELAY_ID_LEN πŸ”’
MAX_WAIT πŸ”’
SEND_WIDTH πŸ”’

FunctionsΒ§

conflict πŸ”’
limit_exceeded πŸ”’
log_send_error πŸ”’
Logs a failed send, at warning level only when the server is at fault.
outcome πŸ”’
Records a send’s outcome with the time it was finalised.
read_event πŸ”’

Type AliasesΒ§

DelayId
A delay_id, as this server issues it or a client names it.