Parakeet is a Rust-based Bluesky AppView aiming to implement most of the functionality required to support the Bluesky client
1use figment::providers::{Env, Format, Toml};
2use figment::Figment;
3use serde::Deserialize;
4
5pub(crate) fn load_config() -> eyre::Result<Config> {
6 let conf = Figment::new()
7 .merge(Toml::file("Config.toml"))
8 .merge(Env::prefixed("PKC_").split("__"))
9 .extract()?;
10
11 Ok(conf)
12}
13
14#[derive(Debug, Deserialize)]
15pub struct Config {
16 #[serde(flatten)]
17 pub instruments: ConfigInstruments,
18 pub index_uri: String,
19 pub database: deadpool_postgres::Config,
20 pub redis_uri: String,
21 pub plc_directory: Option<String>,
22 /// Adds contact details (email / bluesky handle / website) to the UA header.
23 pub ua_contact: Option<String>,
24 pub label_source: Option<String>,
25 /// Where to store the resume information for labels and indexer only.
26 pub resume_path: Option<String>,
27
28 /// Configuration items specific to indexer
29 pub indexer: Option<IndexerConfig>,
30 /// Configuration items specific to backfill
31 pub backfill: Option<BackfillConfig>,
32}
33
34#[derive(Debug, Deserialize)]
35pub struct ConfigInstruments {
36 #[serde(default)]
37 pub log_json: bool,
38}
39
40#[derive(Debug, Deserialize)]
41pub struct IndexerConfig {
42 pub relay_source: String,
43 pub history_mode: HistoryMode,
44 #[serde(default = "default_indexer_workers")]
45 pub workers: u8,
46 pub start_commit_seq: Option<u64>,
47 /// Whether to resolve handles as part of `#identity` events.
48 /// You can use this to move handle resolution out of event handling and into another place.
49 #[serde(default)]
50 pub skip_handle_validation: bool,
51 /// Whether to submit backfill requests for new repos. (Only when history_mode == BackfillHistory).
52 #[serde(default)]
53 pub request_backfill: bool,
54}
55
56#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Deserialize)]
57#[serde(rename_all = "snake_case")]
58pub enum HistoryMode {
59 /// Attempt to backfill **all** history from each (discovered) repo using the PDS
60 BackfillHistory,
61 /// Discover new accounts as they come and do not import history
62 Realtime,
63}
64
65#[derive(Clone, Debug, Deserialize)]
66pub struct BackfillConfig {
67 #[serde(default = "default_backfill_workers")]
68 pub workers: u8,
69 #[serde(default)]
70 pub skip_aggregation: bool,
71 #[serde(default = "default_download_workers")]
72 pub download_workers: usize,
73 #[serde(default = "default_download_buffer")]
74 pub download_buffer: usize,
75 pub download_tmp_dir: String,
76}
77
78fn default_backfill_workers() -> u8 {
79 4
80}
81
82fn default_indexer_workers() -> u8 {
83 4
84}
85
86fn default_download_workers() -> usize {
87 25
88}
89
90fn default_download_buffer() -> usize {
91 25_000
92}