1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Startup-time validation that the database URL scheme is PostgreSQL.
//!
//! `fraiseql-server` and `fraiseql run` validate the URL scheme at startup.
//! FraiseQL is PostgreSQL-only: MySQL, SQLite and SQL Server support was
//! removed (G2 decision on #374; the dialects were never production-correct —
//! see #721/#799 and the issues they reference).
//!
//! Without this guard, pointing the binary at a URL whose scheme is unknown
//! would produce an opaque error from deep inside the driver layer
//! (connection refused, protocol mismatch, or worse). This module fails fast
//! at startup with a diagnostic naming the observed scheme so an operator can
//! correct the configuration. URLs for the *removed* engines get a dedicated
//! message naming the removal, so an operator upgrading across the de-scope
//! release learns what happened rather than guessing at a typo.
/// Operator-facing sentinel embedded in every guard error message.
///
/// Tests assert against this prefix so the diagnostic stays grep-able from
/// logs even if surrounding wording is reflowed.
pub const GUARD_MESSAGE_PREFIX: &str = "fraiseql-server: unsupported database URL";
/// Database schemes that the `fraiseql-server` binary can dispatch to.
///
/// The enum is exhaustive: every variant corresponds to an adapter that
/// `main()` / `fraiseql run` know how to construct. New schemes require an
/// explicit code change here and matching dispatch arms.
/// Parse the URL scheme from a database URL and return the matching
/// [`DatabaseScheme`].
///
/// # Errors
///
/// Returns `anyhow::Error` whose message starts with [`GUARD_MESSAGE_PREFIX`]
/// when the URL has no scheme, an empty scheme, or a scheme other than
/// PostgreSQL. The removed engines (`mysql://`, `sqlite://`, `sqlserver://`)
/// get a message naming the removal; anything else names the observed scheme
/// so the operator can correct their `fraiseql.toml` or `DATABASE_URL`.