]> Untitled Git - lemmy.git/blobdiff - crates/utils/src/settings/structs.rs
Remove `actix_rt` & use standard tokio spawn (#3158)
[lemmy.git] / crates / utils / src / settings / structs.rs
index c135c3a8ca3896234a7be686cacada73b91c2071..5d0e642f6a2a55787ebfe7c34e2b5a20c67f8207 100644 (file)
@@ -39,6 +39,12 @@ pub struct Settings {
   #[default(None)]
   #[doku(skip)]
   pub opentelemetry_url: Option<Url>,
+  /// The number of activitypub federation workers that can be in-flight concurrently
+  #[default(0)]
+  pub worker_count: usize,
+  /// The number of activitypub federation retry workers that can be in-flight concurrently
+  #[default(0)]
+  pub retry_count: usize,
 }
 
 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
@@ -55,8 +61,49 @@ pub struct PictrsConfig {
 }
 
 #[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
-#[serde(default, deny_unknown_fields)]
+#[serde(default)]
 pub struct DatabaseConfig {
+  #[serde(flatten, default)]
+  pub connection: DatabaseConnection,
+
+  /// Maximum number of active sql connections
+  #[default(5)]
+  pub pool_size: usize,
+}
+
+#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
+#[serde(untagged)]
+pub enum DatabaseConnection {
+  /// Configure the database by specifying a URI
+  ///
+  /// This is the preferred method to specify database connection details since
+  /// it is the most flexible.
+  Uri {
+    /// Connection URI pointing to a postgres instance
+    ///
+    /// This example uses peer authentication to obviate the need for creating,
+    /// configuring, and managing passwords.
+    ///
+    /// For an explanation of how to use connection URIs, see [here][0] in
+    /// PostgreSQL's documentation.
+    ///
+    /// [0]: https://www.postgresql.org/docs/current/libpq-connect.html#id-1.7.3.8.3.6
+    #[doku(example = "postgresql:///lemmy?user=lemmy&host=/var/run/postgresql")]
+    uri: String,
+  },
+
+  /// Configure the database by specifying parts of a URI
+  ///
+  /// Note that specifying the `uri` field should be preferred since it provides
+  /// greater control over how the connection is made. This merely exists for
+  /// backwards-compatibility.
+  #[default]
+  Parts(DatabaseConnectionParts),
+}
+
+#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
+#[serde(default)]
+pub struct DatabaseConnectionParts {
   /// Username to connect to postgres
   #[default("lemmy")]
   pub(super) user: String,
@@ -72,9 +119,6 @@ pub struct DatabaseConfig {
   /// Name of the postgres database for lemmy
   #[default("lemmy")]
   pub(super) database: String,
-  /// Maximum number of active sql connections
-  #[default(5)]
-  pub pool_size: usize,
 }
 
 #[derive(Debug, Deserialize, Serialize, Clone, Document, SmartDefault)]