linera_service/cli_wrappers/
mod.rs1#[cfg(feature = "kubernetes")]
8pub mod docker;
10
11#[cfg(feature = "kubernetes")]
12mod helmfile;
14#[cfg(feature = "kubernetes")]
15mod kind;
17#[cfg(feature = "kubernetes")]
18mod kubectl;
20#[cfg(feature = "kubernetes")]
21pub mod local_kubernetes_net;
23pub mod local_net;
25#[cfg(all(with_testing, feature = "remote-net"))]
26pub mod remote_net;
28#[cfg(feature = "kubernetes")]
29mod util;
31mod wallet;
33
34use anyhow::Result;
35use async_trait::async_trait;
36pub use linera_faucet_client::Faucet;
37#[cfg(with_testing)]
38pub use wallet::NotificationsExt;
39pub use wallet::{ApplicationWrapper, ClientWrapper, FaucetService, NodeService, OnClientDrop};
40
41#[async_trait]
43pub trait LineraNetConfig {
44 type Net: LineraNet + Sized + Send + Sync + 'static;
45
46 async fn instantiate(self) -> Result<(Self::Net, ClientWrapper)>;
47}
48
49#[async_trait]
51pub trait LineraNet {
52 async fn ensure_is_running(&mut self) -> Result<()>;
53
54 async fn make_client(&mut self) -> ClientWrapper;
55
56 async fn terminate(&mut self) -> Result<()>;
57}
58
59#[derive(Copy, Clone)]
61pub enum Network {
62 Grpc,
63 Grpcs,
64 Tcp,
65 Udp,
66}
67
68#[derive(Copy, Clone)]
70pub struct NetworkConfig {
71 pub internal: Network,
73 pub external: Network,
75}
76
77impl Network {
78 fn toml(&self) -> &'static str {
79 match self {
80 Network::Grpc => "{ Grpc = \"ClearText\" }",
81 Network::Grpcs => "{ Grpc = \"Tls\" }",
82 Network::Tcp => "{ Simple = \"Tcp\" }",
83 Network::Udp => "{ Simple = \"Udp\" }",
84 }
85 }
86
87 pub fn short(&self) -> &'static str {
88 match self {
89 Network::Grpc => "grpc",
90 Network::Grpcs => "grpcs",
91 Network::Tcp => "tcp",
92 Network::Udp => "udp",
93 }
94 }
95
96 pub fn drop_tls(&self) -> Self {
97 match self {
98 Network::Grpc => Network::Grpc,
99 Network::Grpcs => Network::Grpc,
100 Network::Tcp => Network::Tcp,
101 Network::Udp => Network::Udp,
102 }
103 }
104
105 pub fn localhost(&self) -> &'static str {
106 match self {
107 Network::Grpc | Network::Grpcs => "localhost",
108 Network::Tcp | Network::Udp => "127.0.0.1",
109 }
110 }
111
112 pub fn schema(&self) -> &'static str {
114 match self {
115 Network::Grpc | Network::Grpcs => "grpc",
116 Network::Tcp => "tcp",
117 Network::Udp => "udp",
118 }
119 }
120}