pub struct TunnelConnection {
pub tunnel_id: String,
pub ws_sender: WsSender,
pub pending_requests: DashMap<String, PendingRequest>,
pub created_at: DateTime<Utc>,
pub last_activity: RwLock<DateTime<Utc>>,
pub source_ip: String,
}Expand description
Represents an active tunnel connection from a local agent
Fields§
§tunnel_id: StringUnique tunnel identifier
ws_sender: WsSenderWebSocket sender for sending messages to the agent
pending_requests: DashMap<String, PendingRequest>Pending HTTP requests awaiting responses
created_at: DateTime<Utc>Creation timestamp
last_activity: RwLock<DateTime<Utc>>Last activity timestamp
source_ip: StringSource IP address
Implementations§
Source§impl TunnelConnection
impl TunnelConnection
Sourcepub fn new(tunnel_id: String, ws_sender: WsSender, source_ip: String) -> Self
pub fn new(tunnel_id: String, ws_sender: WsSender, source_ip: String) -> Self
Create a new tunnel connection
Sourcepub async fn send_encrypted(
&self,
message_type: u8,
encrypted: Vec<u8>,
) -> Result<()>
pub async fn send_encrypted( &self, message_type: u8, encrypted: Vec<u8>, ) -> Result<()>
Send a data message through the tunnel (already encrypted)
Sourcepub fn register_request(&self, request_id: String) -> Receiver<DataMessage>
pub fn register_request(&self, request_id: String) -> Receiver<DataMessage>
Register a pending request and get a receiver for the response
Sourcepub fn register_streaming_request(
&self,
request_id: String,
) -> Receiver<DataMessage>
pub fn register_streaming_request( &self, request_id: String, ) -> Receiver<DataMessage>
Register a streaming request (for SSE) and get a receiver for chunks
Sourcepub fn complete_request(&self, request_id: &str, response: DataMessage) -> bool
pub fn complete_request(&self, request_id: &str, response: DataMessage) -> bool
Complete a pending request with a response
Sourcepub async fn send_chunk(&self, request_id: &str, chunk: DataMessage) -> bool
pub async fn send_chunk(&self, request_id: &str, chunk: DataMessage) -> bool
Send a chunk to a streaming request (returns false if request not found or not streaming)
Sourcepub fn complete_streaming_request(&self, request_id: &str)
pub fn complete_streaming_request(&self, request_id: &str)
Complete a streaming request (removes it from pending)
Sourcepub fn cancel_all_requests(&self)
pub fn cancel_all_requests(&self)
Cancel all pending requests (called on disconnect)
Auto Trait Implementations§
impl !Freeze for TunnelConnection
impl !RefUnwindSafe for TunnelConnection
impl !UnwindSafe for TunnelConnection
impl Send for TunnelConnection
impl Sync for TunnelConnection
impl Unpin for TunnelConnection
impl UnsafeUnpin for TunnelConnection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more