Skip to main content

forge_runtime/
lib.rs

1//! Forge runtime engine.
2
3pub use sqlx;
4
5pub mod cluster;
6pub mod function;
7pub mod kv;
8pub mod observability;
9pub mod pg;
10pub mod rate_limit;
11pub(crate) mod stable_hash;
12
13#[cfg(feature = "cron")]
14pub mod cron;
15#[cfg(feature = "daemons")]
16pub mod daemon;
17#[cfg(feature = "gateway")]
18pub mod gateway;
19#[cfg(feature = "jobs")]
20pub mod jobs;
21#[cfg(feature = "gateway")]
22pub mod mcp;
23#[cfg(feature = "gateway")]
24pub mod realtime;
25#[cfg(feature = "gateway")]
26pub mod webhook;
27#[cfg(feature = "workflows")]
28pub mod workflow;
29
30// No-op stubs when `gateway` is off so callers don't need cfg gates.
31#[cfg(feature = "gateway")]
32pub mod signals;
33#[cfg(not(feature = "gateway"))]
34pub mod signals {
35    use forge_core::signals::SignalEvent;
36
37    #[inline]
38    pub fn emit_raw(_event: SignalEvent) {}
39
40    #[inline]
41    pub fn emit_server_execution(
42        _name: &str,
43        _kind: &str,
44        _duration_ms: i32,
45        _success: bool,
46        _error_message: Option<String>,
47    ) {
48    }
49
50    #[inline]
51    #[allow(clippy::too_many_arguments)]
52    pub fn emit_diagnostic(
53        _event_name: &str,
54        _properties: serde_json::Value,
55        _client_ip: Option<String>,
56        _user_agent: Option<String>,
57        _visitor_id: Option<String>,
58        _user_id: Option<uuid::Uuid>,
59        _is_bot: bool,
60    ) {
61    }
62
63    #[inline]
64    pub fn install_global(_: Option<()>) {}
65
66    pub mod bot {
67        #[inline]
68        pub fn is_bot(_user_agent: Option<&str>) -> bool {
69            false
70        }
71    }
72
73    pub mod visitor {
74        pub fn generate_visitor_id(
75            _client_ip: Option<&str>,
76            _user_agent: Option<&str>,
77            _server_secret: &str,
78        ) -> String {
79            String::new()
80        }
81    }
82}
83
84pub use cluster::{GracefulShutdown, HeartbeatConfig, HeartbeatLoop, NodeRegistry, ShutdownConfig};
85pub use function::{FunctionRegistry, RouteOutcome};
86pub use kv::KvStore;
87pub use observability::{TelemetryConfig, init_telemetry, shutdown_telemetry};
88pub use pg::{
89    AppliedMigration, Database, DriftStatus, Migration, MigrationRunner, MigrationStatus,
90    load_migrations_from_dir,
91};
92pub use pg::{LeaderConfig, LeaderElection, PgNotifyBus};
93pub use rate_limit::{HybridRateLimiter, StrictRateLimiter};
94
95#[cfg(feature = "cron")]
96pub use cron::{CronRegistry, CronRunner};
97#[cfg(feature = "daemons")]
98pub use daemon::{DaemonRegistry, DaemonRunner, DaemonRunnerConfig};
99#[cfg(feature = "gateway")]
100pub use gateway::{GatewayConfig, GatewayServer};
101#[cfg(feature = "jobs")]
102pub use jobs::{JobDispatcher, JobQueue, JobRegistry, Worker, WorkerConfig};
103#[cfg(feature = "gateway")]
104pub use mcp::McpToolRegistry;
105#[cfg(feature = "gateway")]
106pub use realtime::RealtimeConfig;
107#[cfg(feature = "gateway")]
108pub use webhook::{WebhookRegistry, WebhookState, webhook_handler};
109#[cfg(feature = "workflows")]
110pub use workflow::{
111    EventStore, WorkflowExecutor, WorkflowRegistry, WorkflowScheduler, WorkflowSchedulerConfig,
112};