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
16 changes: 8 additions & 8 deletions src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,10 @@ impl Dispatcher {
}
}

fn on_downstream_close(&self, context_id: u32, peer_type: PeerType) {
fn on_downstream_close(&self, context_id: u32, close_type: CloseType) {
if let Some(stream) = self.streams.borrow_mut().get_mut(&context_id) {
self.active_id.set(context_id);
stream.on_downstream_close(peer_type)
stream.on_downstream_close(close_type)
} else {
panic!("invalid context_id")
}
Expand All @@ -302,10 +302,10 @@ impl Dispatcher {
}
}

fn on_upstream_close(&self, context_id: u32, peer_type: PeerType) {
fn on_upstream_close(&self, context_id: u32, close_type: CloseType) {
if let Some(stream) = self.streams.borrow_mut().get_mut(&context_id) {
self.active_id.set(context_id);
stream.on_upstream_close(peer_type)
stream.on_upstream_close(close_type)
} else {
panic!("invalid context_id")
}
Expand Down Expand Up @@ -458,8 +458,8 @@ pub extern "C" fn proxy_on_downstream_data(
}

#[no_mangle]
pub extern "C" fn proxy_on_downstream_connection_close(context_id: u32, peer_type: PeerType) {
DISPATCHER.with(|dispatcher| dispatcher.on_downstream_close(context_id, peer_type))
pub extern "C" fn proxy_on_downstream_connection_close(context_id: u32, close_type: CloseType) {
DISPATCHER.with(|dispatcher| dispatcher.on_downstream_close(context_id, close_type))
}

#[no_mangle]
Expand All @@ -472,8 +472,8 @@ pub extern "C" fn proxy_on_upstream_data(
}

#[no_mangle]
pub extern "C" fn proxy_on_upstream_connection_close(context_id: u32, peer_type: PeerType) {
DISPATCHER.with(|dispatcher| dispatcher.on_upstream_close(context_id, peer_type))
pub extern "C" fn proxy_on_upstream_connection_close(context_id: u32, close_type: CloseType) {
DISPATCHER.with(|dispatcher| dispatcher.on_upstream_close(context_id, close_type))
}

#[no_mangle]
Expand Down
4 changes: 2 additions & 2 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ pub trait StreamContext: Context {
hostcalls::get_buffer(BufferType::DownstreamData, start, max_size).unwrap()
}

fn on_downstream_close(&mut self, _peer_type: PeerType) {}
fn on_downstream_close(&mut self, _close_type: CloseType) {}

fn on_upstream_data(&mut self, _data_size: usize, _end_of_stream: bool) -> Action {
Action::Continue
Expand All @@ -155,7 +155,7 @@ pub trait StreamContext: Context {
hostcalls::get_buffer(BufferType::UpstreamData, start, max_size).unwrap()
}

fn on_upstream_close(&mut self, _peer_type: PeerType) {}
fn on_upstream_close(&mut self, _close_type: CloseType) {}

fn on_log(&mut self) {}
}
Expand Down
8 changes: 7 additions & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub type NewHttpContext = fn(context_id: u32, root_context_id: u32) -> Box<dyn H

#[repr(u32)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
#[non_exhaustive]
pub enum LogLevel {
Trace = 0,
Debug = 1,
Expand All @@ -34,13 +35,15 @@ pub enum LogLevel {

#[repr(u32)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
#[non_exhaustive]
pub enum Action {
Continue = 0,
Pause = 1,
}

#[repr(u32)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
#[non_exhaustive]
pub enum Status {
Ok = 0,
NotFound = 1,
Expand All @@ -52,6 +55,7 @@ pub enum Status {

#[repr(u32)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
#[non_exhaustive]
pub enum BufferType {
HttpRequestBody = 0,
HttpResponseBody = 1,
Expand All @@ -62,6 +66,7 @@ pub enum BufferType {

#[repr(u32)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
#[non_exhaustive]
pub enum MapType {
HttpRequestHeaders = 0,
HttpRequestTrailers = 1,
Expand All @@ -73,7 +78,8 @@ pub enum MapType {

#[repr(u32)]
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub enum PeerType {
#[non_exhaustive]
pub enum CloseType {
Unknown = 0,
Local = 1,
Remote = 2,
Expand Down