forge
ExploreLog in

Tahinli/forge

public
0 watching
★ 0
2.2 KiB
1//! Shared application state handed to every router via Topcoat's app context.
2
3use std::path::PathBuf;
4use std::sync::Arc;
5
6use forge_core::{Config, Store};
7use forge_git::GitEnv;
8use tokio::sync::Notify;
9
10use crate::throttle::Throttle;
11
12#[derive(Clone)]
13pub struct AppState {
14 pub config: Arc<Config>,
15 pub store: Store,
16 pub git: Arc<GitEnv>,
17 /// Instance secret key (data_dir/forge.key). Signs private raw-file URLs.
18 pub key: Arc<[u8; 32]>,
19 /// Random per boot. Presented by hook processes on the internal API.
20 pub internal_token: Arc<str>,
21 /// Per boot. Presented by the CLI on the `/internal/admin/*` routes. Also written to
22 /// `data_dir/run/admin.token` with mode 0600, which is how the CLI reads it.
23 pub admin_token: Arc<str>,
24 /// The single backup and fsck run slot of this process.
25 pub jobs: Arc<crate::backup::Jobs>,
26 /// Absolute path to the internal unix socket (data_dir/internal.sock).
27 pub internal_socket: PathBuf,
28 /// Failed-authentication counters for login and git HTTP. Shared by every request.
29 pub throttle: Arc<Throttle>,
30 /// Wakes the webhook delivery worker when a delivery is queued.
31 pub webhook_waker: Arc<Notify>,
32 /// Wakes the mirror worker on "sync now" and after a push to a repo with push mirrors.
33 pub mirror_waker: Arc<Notify>,
34 /// Release asset bytes under `data_dir/blobs`.
35 pub blobs: crate::blobs::BlobStore,
36 /// Standby replication queue: repos to push after a ref update, and the reconcile-now flag.
37 pub replication: Arc<crate::replication::ReplicationQueue>,
38 /// Wakes long-polling runner claims when a CI job becomes Queued.
39 pub ci_waker: Arc<Notify>,
40 /// Outgoing mail transport: SMTP, or the log transport in dev and tests.
41 pub mailer: Arc<dyn crate::mail::Mailer>,
42 /// Wakes the mail worker when a message is queued or the mail settings change.
43 pub mail_waker: Arc<Notify>,
44 /// Open notification streams per user. A change to an inbox publishes the new unread count.
45 pub notify_hub: Arc<crate::notify_hub::NotifyHub>,
46 /// Change counters of CI jobs and runs. Log followers and run pages wait on them.
47 pub ci_live: Arc<crate::ci::CiLive>,
48}