Skip to main content

Module email

Module email 

Source
Expand description

Email notifications for the email pusher kind.

A notifying event for a user with an email pusher wakes the worker, which waits out the configured delay and then mails every notification still unread in one message. The pending work is derived from the stored notification rows; only a cursor per pusher, and a throttle per room it has mailed about, are kept beside them, so a restart loses no pending mail of a pusher whose cursor has started.

Re-exportsΒ§

use std::collections::BTreeMap; πŸ”’
use std::pin::pin; πŸ”’
use std::time::Duration; πŸ”’
use futures::FutureExt; πŸ”’
use futures::StreamExt; πŸ”’
use futures::future::Either; πŸ”’
use futures::future::select; πŸ”’
use futures::stream::unfold; πŸ”’
use loole::Receiver; πŸ”’
use loole::Sender; πŸ”’
use loole::unbounded; πŸ”’
use ruma::OwnedUserId; πŸ”’
use ruma::UserId; πŸ”’
use ruma::api::client::push::PusherKind; πŸ”’
use ruma::api::client::push::set_pusher::v3::PusherAction; πŸ”’
use tokio::time::Instant; πŸ”’
use tokio::time::sleep_until; πŸ”’
use tuwunel_core::Result; πŸ”’
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::OptionExt; πŸ”’
use tuwunel_core::utils::exponential_backoff_remaining; πŸ”’
use tuwunel_core::utils::stream::TryIgnore; πŸ”’
use tuwunel_core::utils::time::now_millis; πŸ”’
use tuwunel_core::warn; πŸ”’
use tuwunel_database::Deserialized; πŸ”’
use tuwunel_database::Interfix; πŸ”’
use tuwunel_database::Json; πŸ”’
pub use self::evaluate::Outcome;

ModulesΒ§

evaluate πŸ”’
render πŸ”’

StructsΒ§

Entry πŸ”’
Wakes πŸ”’
The worker’s channel, carrying one wake per notification.

EnumsΒ§

Next πŸ”’

ConstantsΒ§

BOOT_GRACE πŸ”’
The wait after startup before evaluating the pushers that had work.
RETRY_MAX πŸ”’
RETRY_MIN πŸ”’
WAIT_MAX πŸ”’
The longest any pusher waits, whatever the configured delay.

FunctionsΒ§

entry_in πŸ”’
kept_frontier πŸ”’
The frontier kept for a pusher whose cursor could not be started, if any.
next_entry πŸ”’
The entry a pusher gets after an outcome, if any.
pusher_key πŸ”’
reschedule πŸ”’
Applies an outcome to a pusher that fell due.
woken πŸ”’
Adds a woken pusher, or brings its entry forward to the sooner due time.

Type AliasesΒ§

Locks πŸ”’
Serializes the writes to each email pusher’s rows.
PushKey πŸ”’
PusherKey πŸ”’
One email pusher: its user, and its pushkey.
Schedule πŸ”’
The email pushers with pending work and when each is next evaluated.
Wake πŸ”’
The pusher one notification wakes, and the frontier of retired writes when the wake was sent.