reactive_graph_runtime_api/
runtime.rs

1use std::time::Duration;
2
3use async_trait::async_trait;
4use reactive_graph_behaviour_service_api::BehaviourSystem;
5use springtime_di::injectable;
6use tokio::time::error::Elapsed;
7
8use reactive_graph_command_api::CommandSystem;
9use reactive_graph_config_api::ConfigSystem;
10use reactive_graph_dynamic_graph_api::DynamicGraphSystem;
11use reactive_graph_graphql_api::GraphQLSystem;
12use reactive_graph_instance_system_api::InstanceSystem;
13use reactive_graph_lifecycle::Lifecycle;
14use reactive_graph_plugin_graphql_api::PluginGraphQLSystem;
15use reactive_graph_plugin_service_api::PluginSystem;
16use reactive_graph_reactive_service_api::ReactiveSystem;
17use reactive_graph_remotes_api::RemotesSystem;
18use reactive_graph_remotes_model::InstanceAddress;
19use reactive_graph_runtime_graphql_api::RuntimeGraphQLSystem;
20use reactive_graph_runtime_service_api::RuntimeSystem;
21use reactive_graph_runtime_web_api::WebSystem;
22use reactive_graph_type_system_api::TypeSystem;
23
24#[async_trait]
25#[injectable]
26pub trait Runtime:
27    TypeSystem
28    + CommandSystem
29    + ConfigSystem
30    + GraphQLSystem
31    + DynamicGraphSystem
32    + RuntimeGraphQLSystem
33    + PluginGraphQLSystem
34    + RemotesSystem
35    + PluginSystem
36    + BehaviourSystem
37    + InstanceSystem
38    + ReactiveSystem
39    + RuntimeSystem
40    + WebSystem
41    + Send
42    + Sync
43    + Lifecycle
44{
45    async fn config(&self);
46
47    async fn run(&self);
48
49    fn stop(&self);
50
51    fn is_running(&self) -> bool;
52
53    /// Waits for the GraphQL server to be started.
54    /// Times out if the GraphQL server is not running after the given duration.
55    async fn wait_for_started(&self, timeout_duration: Duration) -> Result<(), Elapsed>;
56
57    /// Waits for the GraphQL server has been stopped.
58    async fn wait_for_stopped(&self);
59
60    /// Waits for the GraphQL server has been stopped.
61    /// Times out if the GraphQL server is still running after the given duration.
62    async fn wait_for_stopped_with_timeout(&self, timeout_duration: Duration) -> Result<(), Elapsed>;
63
64    /// Returns the address of the runtime.
65    fn address(&self) -> InstanceAddress;
66}