#[cfg(feature = "kubernetes")]
pub mod docker;
#[cfg(feature = "kubernetes")]
mod helmfile;
#[cfg(feature = "kubernetes")]
mod kind;
#[cfg(feature = "kubernetes")]
mod kubectl;
#[cfg(feature = "kubernetes")]
pub mod local_kubernetes_net;
pub mod local_net;
#[cfg(all(with_testing, feature = "remote-net"))]
pub mod remote_net;
#[cfg(feature = "kubernetes")]
mod util;
mod wallet;
use anyhow::Result;
use async_trait::async_trait;
pub use linera_faucet_client::Faucet;
pub use wallet::{
ApplicationWrapper, ClientWrapper, FaucetOption, FaucetService, NodeService, OnClientDrop,
};
#[async_trait]
pub trait LineraNetConfig {
type Net: LineraNet + Sized + Send + Sync + 'static;
async fn instantiate(self) -> Result<(Self::Net, ClientWrapper)>;
}
#[async_trait]
pub trait LineraNet {
async fn ensure_is_running(&mut self) -> Result<()>;
async fn make_client(&mut self) -> ClientWrapper;
async fn terminate(&mut self) -> Result<()>;
}
#[derive(Copy, Clone)]
pub enum Network {
Grpc,
Grpcs,
Tcp,
Udp,
}
#[derive(Copy, Clone)]
pub struct NetworkConfig {
pub internal: Network,
pub external: Network,
}
impl Network {
fn toml(&self) -> &'static str {
match self {
Network::Grpc => "{ Grpc = \"ClearText\" }",
Network::Grpcs => "{ Grpc = \"Tls\" }",
Network::Tcp => "{ Simple = \"Tcp\" }",
Network::Udp => "{ Simple = \"Udp\" }",
}
}
pub fn short(&self) -> &'static str {
match self {
Network::Grpc => "grpc",
Network::Grpcs => "grpcs",
Network::Tcp => "tcp",
Network::Udp => "udp",
}
}
pub fn drop_tls(&self) -> Self {
match self {
Network::Grpc => Network::Grpc,
Network::Grpcs => Network::Grpc,
Network::Tcp => Network::Tcp,
Network::Udp => Network::Udp,
}
}
pub fn localhost(&self) -> &'static str {
match self {
Network::Grpc | Network::Grpcs => "localhost",
Network::Tcp | Network::Udp => "127.0.0.1",
}
}
pub fn schema(&self) -> &'static str {
match self {
Network::Grpc | Network::Grpcs => "grpc",
Network::Tcp => "tcp",
Network::Udp => "udp",
}
}
}