Skip to main content

systemprompt_models/profile/
database.rs

1//! Database configuration.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use serde::{Deserialize, Serialize};
7
8/// Operator-tunable connection-pool sizing.
9///
10/// Omitted fields fall back to the engine defaults (50 connections, 30s
11/// acquire, 300s idle, 1800s lifetime); set them to fit the pool to the
12/// deployment's Postgres `max_connections` and replica count.
13/// [`crate::profile::Profile::validate`] range-checks the values at bootstrap.
14#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, schemars::JsonSchema)]
15#[serde(deny_unknown_fields)]
16pub struct PoolConfig {
17    #[serde(default, skip_serializing_if = "Option::is_none")]
18    pub max_connections: Option<u32>,
19
20    #[serde(default, skip_serializing_if = "Option::is_none")]
21    pub acquire_timeout_secs: Option<u64>,
22
23    #[serde(default, skip_serializing_if = "Option::is_none")]
24    pub idle_timeout_secs: Option<u64>,
25
26    #[serde(default, skip_serializing_if = "Option::is_none")]
27    pub max_lifetime_secs: Option<u64>,
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
31#[serde(deny_unknown_fields)]
32pub struct DatabaseConfig {
33    #[serde(rename = "type")]
34    pub db_type: String,
35
36    #[serde(default)]
37    pub external_db_access: bool,
38
39    #[serde(default, skip_serializing_if = "Option::is_none")]
40    pub pool: Option<PoolConfig>,
41}