Starts the main graph API server (REST + optional RPC).
(
pool: S,
config: ServerConfig,
query_logger: Option<QueryLogger>,
lifecycle: &ServerLifecycle,
)
| 313 | |
| 314 | /// Starts the main graph API server (REST + optional RPC). |
| 315 | async fn start_server<S>( |
| 316 | pool: S, |
| 317 | config: ServerConfig, |
| 318 | query_logger: Option<QueryLogger>, |
| 319 | lifecycle: &ServerLifecycle, |
| 320 | ) -> Result<(), Report<GraphError>> |
| 321 | where |
| 322 | S: StorePool + Send + Sync + 'static, |
| 323 | for<'p> S::Store<'p>: RestApiStore + PrincipalStore + PolicyStore, |
| 324 | { |
| 325 | let store = Arc::new(pool); |
| 326 | let temporal_client = create_temporal_client(&config.temporal) |
| 327 | .await? |
| 328 | .map(Arc::new); |
| 329 | |
| 330 | if config.rpc_enabled { |
| 331 | tracing::info!("Starting RPC server..."); |
| 332 | |
| 333 | start_rpc_server( |
| 334 | config.rpc_address, |
| 335 | Dependencies { |
| 336 | store: Arc::clone(&store), |
| 337 | temporal_client: temporal_client.clone(), |
| 338 | codec: (), |
| 339 | }, |
| 340 | lifecycle, |
| 341 | )?; |
| 342 | } |
| 343 | |
| 344 | let router = rest_api_router(RestRouterDependencies { |
| 345 | store, |
| 346 | domain_regex: DomainValidator::new(config.allowed_url_domain), |
| 347 | temporal_client, |
| 348 | query_logger, |
| 349 | api_config: config.api_config, |
| 350 | }); |
| 351 | start_rest_server(router, config.http_address, lifecycle); |
| 352 | |
| 353 | Ok(()) |
| 354 | } |
| 355 | |
| 356 | #[expect( |
| 357 | clippy::integer_division_remainder_used, |
no test coverage detected