diff --git a/ballista/core/src/transport/channel.rs b/ballista/core/src/transport/channel.rs new file mode 100644 index 000000000..aecd62a28 --- /dev/null +++ b/ballista/core/src/transport/channel.rs @@ -0,0 +1,45 @@ +use std::error::Error; +use std::sync::Arc; + +/// A factory responsible for creating outbound client channels. +/// +/// This abstraction allows different transport implementations +/// (e.g. plain HTTP, TLS) without changing core logic. +pub trait ChannelFactory: Send + Sync { + fn create_channel( + &self, + target: &str, + ) -> Result, Box>; +} +/// Default channel factory using the existing HTTP-based gRPC connection logic. +pub struct DefaultChannelFactory; + +impl ChannelFactory for DefaultChannelFactory { + fn create_channel( + &self, + target: &str, + ) -> Result, Box> { + // NOTE: + // For now, this is a placeholder that will be wired + // to existing client connection logic in the next step. + // + // The purpose here is to establish the factory structure + // without changing behavior. + Err("DefaultChannelFactory not wired yet".into()) + } +} +/// TLS-enabled channel factory (stub). +/// +/// This implementation is intentionally left unimplemented. +/// It exists to demonstrate how TLS support can be plugged in +/// without changing core logic. +pub struct TlsChannelFactory; + +impl ChannelFactory for TlsChannelFactory { + fn create_channel( + &self, + _target: &str, + ) -> Result, Box> { + Err("TlsChannelFactory is not implemented yet".into()) + } +} diff --git a/ballista/core/src/transport/mod.rs b/ballista/core/src/transport/mod.rs new file mode 100644 index 000000000..b760c80d7 --- /dev/null +++ b/ballista/core/src/transport/mod.rs @@ -0,0 +1,2 @@ +pub mod channel; +pub mod server; diff --git a/ballista/core/src/transport/server.rs b/ballista/core/src/transport/server.rs new file mode 100644 index 000000000..f76729b78 --- /dev/null +++ b/ballista/core/src/transport/server.rs @@ -0,0 +1,31 @@ +use std::error::Error; + +/// A factory responsible for creating inbound servers. +/// +/// Implementations may create plain HTTP or TLS-enabled servers. +pub trait ServerFactory: Send + Sync { + fn serve(&self, addr: &str) -> Result<(), Box>; +} +/// Default server factory using the existing HTTP server implementation. +pub struct DefaultServerFactory; + +impl ServerFactory for DefaultServerFactory { + fn serve(&self, _addr: &str) -> Result<(), Box> { + // NOTE: + // This will later delegate to the existing scheduler/executor + // server startup logic. + // + // For now, this is a structural placeholder. + Err("DefaultServerFactory not wired yet".into()) + } +} +/// TLS-enabled server factory (stub). +/// +/// This is a placeholder for future TLS support (e.g. using rustls). +pub struct TlsServerFactory; + +impl ServerFactory for TlsServerFactory { + fn serve(&self, _addr: &str) -> Result<(), Box> { + Err("TlsServerFactory is not implemented yet".into()) + } +}