Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions ballista/core/src/transport/channel.rs
Original file line number Diff line number Diff line change
@@ -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<Arc<dyn std::any::Any + Send + Sync>, Box<dyn Error>>;
}
/// 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<std::sync::Arc<dyn std::any::Any + Send + Sync>, Box<dyn std::error::Error>> {
// 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<std::sync::Arc<dyn std::any::Any + Send + Sync>, Box<dyn std::error::Error>> {
Err("TlsChannelFactory is not implemented yet".into())
}
}
2 changes: 2 additions & 0 deletions ballista/core/src/transport/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod channel;
pub mod server;
31 changes: 31 additions & 0 deletions ballista/core/src/transport/server.rs
Original file line number Diff line number Diff line change
@@ -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<dyn Error>>;
}
/// Default server factory using the existing HTTP server implementation.
pub struct DefaultServerFactory;

impl ServerFactory for DefaultServerFactory {
fn serve(&self, _addr: &str) -> Result<(), Box<dyn std::error::Error>> {
// 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<dyn std::error::Error>> {
Err("TlsServerFactory is not implemented yet".into())
}
}