refactor: drop postgres leftovers, narrow bootstrap api

This commit is contained in:
2026-10-25 23:25:16 +01:00
parent ec2760fd48
commit b7e69b69dc
16 changed files with 277 additions and 58 deletions

View File

@@ -7,7 +7,6 @@ use domain::errors::DomainError;
pub const NOT_FOUND: &str = "NOT_FOUND";
pub const INVALID_INPUT: &str = "INVALID_INPUT";
pub const CONFLICT: &str = "CONFLICT";
pub const UNAUTHORIZED: &str = "UNAUTHORIZED";
pub const FORBIDDEN: &str = "FORBIDDEN";
pub const RATE_LIMITED: &str = "RATE_LIMITED";

View File

@@ -11,10 +11,12 @@ use axum::{
};
use serde::de::DeserializeOwned;
use crate::errors::{INVALID_INPUT, refuse};
use crate::errors::{INTERNAL, INVALID_INPUT, refuse};
/// Malformed request (bad JSON, query or path), refused as `INVALID_INPUT`.
/// Status follows axum: 400 syntax, 415 content type, 422 data errors, 413 size.
/// A rejection with a 5xx status is a server-side fault (e.g. a route that
/// declares no path parameter), refused as `INTERNAL`.
pub struct MalformedRequest {
status: StatusCode,
message: String,
@@ -22,7 +24,12 @@ pub struct MalformedRequest {
impl IntoResponse for MalformedRequest {
fn into_response(self) -> Response {
refuse(self.status, INVALID_INPUT, self.message)
let code = if self.status.is_server_error() {
INTERNAL
} else {
INVALID_INPUT
};
refuse(self.status, code, self.message)
}
}

View File

@@ -38,18 +38,18 @@ pub struct SqliteEventQueue {
}
impl SqliteEventQueue {
pub async fn create(pool: SqlitePool, config: DbEventQueueConfig) -> anyhow::Result<Self> {
Ok(Self {
pub fn create(pool: SqlitePool, config: DbEventQueueConfig) -> Self {
Self {
pool,
config: Arc::new(config),
})
}
}
pub async fn create_publisher(
pool: SqlitePool,
config: &config::EventsConfig,
) -> anyhow::Result<Arc<dyn EventPublisher>> {
let q = Self::create(pool, DbEventQueueConfig::from_config(config)).await?;
let q = Self::create(pool, DbEventQueueConfig::from_config(config));
Ok(Arc::new(q))
}
@@ -57,7 +57,7 @@ impl SqliteEventQueue {
pool: SqlitePool,
config: &config::EventsConfig,
) -> anyhow::Result<(Arc<dyn EventPublisher>, Arc<dyn EventConsumer>)> {
let q = Self::create(pool, DbEventQueueConfig::from_config(config)).await?;
let q = Self::create(pool, DbEventQueueConfig::from_config(config));
Ok((Arc::new(q.clone()), Arc::new(q)))
}
}