forge
Explore
Log in

Don't you dare go Hollow

iz

Clone
★ 0

0 watching0 forksRustAGPL-3.0567.3 KiB3950aceTahinli27 days ago34 commits

state.rs38 lines, 1.8 KiBHistoryRawDownload
1//! The state shared by every route. Topcoat hands it to each handler through the app context.
2
3use std::sync::Arc;
4
5use iz_core::config::Config;
6use iz_core::store::Store;
7
8use crate::backup::BackupTrigger;
9use crate::family::FamilyCache;
10use crate::in_store::InStore;
11use crate::live::LiveHub;
12use crate::oidc::OidcClient;
13
14/// Everything a request handler reaches through the app context. Every field is cheap to clone.
15#[allow(dead_code)] // The hub is read by the live pages that come next.
16#[derive(Clone)]
17pub struct AppState {
18 /// The configuration the process booted with.
19 pub config: Arc<Config>,
20 /// The database. Reads go to a pooled reader and writes to the single writer.
21 pub store: Store,
22 /// The instance key (`iz.key`). Never used directly: sealing and the manifest MAC each derive a subkey.
23 pub key: Arc<[u8; 32]>,
24 /// The change counters of the live pages.
25 pub live: Arc<LiveHub>,
26 /// The `im` client. `None` when no `[oidc]` section is configured, so sign-in is off.
27 pub oidc: Option<Arc<OidcClient>>,
28 /// The family service list that the topbar switcher shows. Filled by the `family` worker.
29 pub family: Arc<FamilyCache>,
30 /// The Files service (`in`). `None` unless `[in_store]` is enabled with a URL and sign-in gives the token.
31 pub in_store: Option<Arc<InStore>>,
32 /// Held around every step that changes where attachment bytes are: a row's claim, flip or removal, a
33 /// local copy's removal, and a Files copy's deletion. The mover and the deleter take it, so a stale record
34 /// can never remove the live copy (see `attachments.rs`).
35 pub blob_lock: Arc<tokio::sync::Mutex<()>>,
36 /// Asks the backup worker for a run now (the settings page). Shared with the worker.
37 pub backup: Arc<BackupTrigger>,
38}