1use std::path::PathBuf;
2
3use async_trait::async_trait;
4pub use configuration::{
5 GlobalSettings, GlobalSettingsBuilder, NetworkConfig, NetworkConfigBuilder,
6 RegistrationStrategy, WithRelaychain,
7};
8pub use orchestrator::{
9 errors::OrchestratorError,
10 network::{node::NetworkNode, Network},
11 sc_chain_spec, AddCollatorOptions, AddNodeOptions, Orchestrator,
12};
13
14pub mod tx_helper {
16 pub use orchestrator::{
17 network::chain_upgrade::ChainUpgrade, shared::types::RuntimeUpgradeOptions,
18 };
19}
20
21use provider::{DockerProvider, KubernetesProvider, NativeProvider};
22pub use support::fs::local::LocalFileSystem;
23
24pub mod environment;
25pub const PROVIDERS: [&str; 3] = ["k8s", "native", "docker"];
26
27pub use subxt;
29pub use subxt_signer;
30
31#[async_trait]
32pub trait NetworkConfigExt {
33 async fn spawn_native(self) -> Result<Network<LocalFileSystem>, OrchestratorError>;
46 async fn spawn_k8s(self) -> Result<Network<LocalFileSystem>, OrchestratorError>;
47 async fn spawn_docker(self) -> Result<Network<LocalFileSystem>, OrchestratorError>;
48}
49
50#[async_trait]
51pub trait AttachToLive {
52 async fn attach_native(
65 zombie_json_path: PathBuf,
66 ) -> Result<Network<LocalFileSystem>, OrchestratorError>;
67 async fn attach_k8s(
68 zombie_json_path: PathBuf,
69 ) -> Result<Network<LocalFileSystem>, OrchestratorError>;
70 async fn attach_docker(
71 zombie_json_path: PathBuf,
72 ) -> Result<Network<LocalFileSystem>, OrchestratorError>;
73}
74
75#[async_trait]
76impl NetworkConfigExt for NetworkConfig {
77 async fn spawn_native(self) -> Result<Network<LocalFileSystem>, OrchestratorError> {
78 let filesystem = LocalFileSystem;
79 let provider = NativeProvider::new(filesystem.clone());
80 let orchestrator = Orchestrator::new(filesystem, provider);
81 orchestrator.spawn(self).await
82 }
83
84 async fn spawn_k8s(self) -> Result<Network<LocalFileSystem>, OrchestratorError> {
85 let filesystem = LocalFileSystem;
86 let provider = KubernetesProvider::new(filesystem.clone()).await;
87 let orchestrator = Orchestrator::new(filesystem, provider);
88 orchestrator.spawn(self).await
89 }
90
91 async fn spawn_docker(self) -> Result<Network<LocalFileSystem>, OrchestratorError> {
92 let filesystem = LocalFileSystem;
93 let provider = DockerProvider::new(filesystem.clone()).await;
94 let orchestrator = Orchestrator::new(filesystem, provider);
95 orchestrator.spawn(self).await
96 }
97}
98
99pub struct AttachToLiveNetwork;
100
101#[async_trait]
102impl AttachToLive for AttachToLiveNetwork {
103 async fn attach_native(
104 zombie_json_path: PathBuf,
105 ) -> Result<Network<LocalFileSystem>, OrchestratorError> {
106 let filesystem = LocalFileSystem;
107 let provider = NativeProvider::new(filesystem.clone());
108 let orchestrator = Orchestrator::new(filesystem, provider);
109 orchestrator.attach_to_live(zombie_json_path.as_ref()).await
110 }
111
112 async fn attach_k8s(
113 zombie_json_path: PathBuf,
114 ) -> Result<Network<LocalFileSystem>, OrchestratorError> {
115 let filesystem = LocalFileSystem;
116 let provider = KubernetesProvider::new(filesystem.clone()).await;
117 let orchestrator = Orchestrator::new(filesystem, provider);
118 orchestrator.attach_to_live(zombie_json_path.as_ref()).await
119 }
120
121 async fn attach_docker(
122 zombie_json_path: PathBuf,
123 ) -> Result<Network<LocalFileSystem>, OrchestratorError> {
124 let filesystem = LocalFileSystem;
125 let provider = DockerProvider::new(filesystem.clone()).await;
126 let orchestrator = Orchestrator::new(filesystem, provider);
127 orchestrator.attach_to_live(zombie_json_path.as_ref()).await
128 }
129}