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;
37pub use wallet::{ApplicationWrapper, ClientWrapper, FaucetService, NodeService, OnClientDrop};
38
39#[async_trait]
41pub trait LineraNetConfig {
42 type Net: LineraNet + Sized + Send + Sync + 'static;
43
44 async fn instantiate(self) -> Result<(Self::Net, ClientWrapper)>;
45}
46
47#[async_trait]
49pub trait LineraNet {
50 async fn ensure_is_running(&mut self) -> Result<()>;
51
52 async fn make_client(&mut self) -> ClientWrapper;
53
54 async fn terminate(&mut self) -> Result<()>;
55}
56
57#[derive(Copy, Clone)]
59pub enum Network {
60 Grpc,
61 Grpcs,
62 Tcp,
63 Udp,
64}
65
66#[derive(Copy, Clone)]
68pub struct NetworkConfig {
69 pub internal: Network,
71 pub external: Network,
73}
74
75impl Network {
76 fn toml(&self) -> &'static str {
77 match self {
78 Network::Grpc => "{ Grpc = \"ClearText\" }",
79 Network::Grpcs => "{ Grpc = \"Tls\" }",
80 Network::Tcp => "{ Simple = \"Tcp\" }",
81 Network::Udp => "{ Simple = \"Udp\" }",
82 }
83 }
84
85 pub fn short(&self) -> &'static str {
86 match self {
87 Network::Grpc => "grpc",
88 Network::Grpcs => "grpcs",
89 Network::Tcp => "tcp",
90 Network::Udp => "udp",
91 }
92 }
93
94 pub fn drop_tls(&self) -> Self {
95 match self {
96 Network::Grpc => Network::Grpc,
97 Network::Grpcs => Network::Grpc,
98 Network::Tcp => Network::Tcp,
99 Network::Udp => Network::Udp,
100 }
101 }
102
103 pub fn localhost(&self) -> &'static str {
104 match self {
105 Network::Grpc | Network::Grpcs => "localhost",
106 Network::Tcp | Network::Udp => "127.0.0.1",
107 }
108 }
109
110 pub fn schema(&self) -> &'static str {
112 match self {
113 Network::Grpc | Network::Grpcs => "grpc",
114 Network::Tcp => "tcp",
115 Network::Udp => "udp",
116 }
117 }
118}