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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//! Library entrypoints for embedding SurrealDB server inside another Rust application.
//! Exposes the same init() used by the `surreal` binary so external apps can
//! start SurrealDB within their own `main()`.
//!
//! <section class="warning">
//! <h3>Unstable!</h3>
//! This crate is <b>SurrealDB internal API</b>. It does not adhere to SemVer and its API is
//! free to change and break code even between patch versions. If you are looking for a stable
//! interface to the SurrealDB library please have a look at
//! <a href="https://crates.io/crates/surrealdb">the Rust SDK</a>.
//! </section>
// Temporarily allow deprecated items until version 3.0 for backward compatibility
extern crate tracing;
/// Make `ntw` public so embedders can access RouterFactory and related networking definitions
/// when running SurrealDB as a library.
/// Observability wiring: community Prometheus registry, `/metrics` handler,
/// and the allowlists controlling what may leave the server unauthenticated.
/// Make `rpc` public so embedders can access RpcState and related router definitions
/// when running SurrealDB as a library.
/// Process-wide rustls `CryptoProvider` installation. Public so embedders and
/// downstream binaries (e.g. the Enterprise cluster transport) can install
/// the same provider — including the FIPS-validated provider when built with
/// `feature = "fips"` — instead of duplicating the install logic.
use Future;
use ExitCode;
pub use ;
/// Re-export `RouterFactory` for convenience so embedders can `use
/// surrealdb_server::RouterFactory`.
pub use RouterFactory;
/// Re-export `RouterOptions` for convenience so embedders can `use
/// surrealdb_server::RouterOptions`.
pub use RouterOptions;
/// Re-export `SurrealRouter` for convenience so embedders can `use
/// surrealdb_server::SurrealRouter`.
pub use SurrealRouter;
/// Re-export `RpcState` for convenience so embedders can `use surrealdb_server::RpcState`.
pub use RpcState;
pub use surrealdb as sdk;
/// Re-export `core` for convenience so embedders can `use surrealdb_server::core::...`.
pub use surrealdb_core as core;
use BucketStoreProvider;
use TransactionBuilderFactory;
// Re-export the core crate in the same path used across internal modules
// so that `crate::core::...` keeps working when used as a library target.
/// Initialize SurrealDB CLI/server with the same behavior as the `surreal` binary.
/// This spins up a Tokio runtime with a larger stack size and then runs the CLI
/// entrypoint (which starts the server when the `start` subcommand is used).
///
/// # Parameters
/// - `composer`: A composer implementing the required traits for dependency injection.
///
/// # Generic parameters
/// - `C`: A composer type that implements:
/// - `TransactionBuilderFactory` (selects/validates the datastore backend)
/// - `RouterFactory` (constructs the HTTP router)
/// - `ConfigCheck` (validates configuration before initialization)
/// Rust's default thread stack size of 2MiB doesn't allow sufficient recursion depth
/// for SurrealDB's query parser and execution engine. This function creates a Tokio
/// runtime with a larger stack size configured via `cnf::RUNTIME_STACK_SIZE`.