mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-08 22:38:01 -06:00
Add stateful call leaf runtime
This commit is contained in:
@@ -205,6 +205,7 @@ impl ProtocolEndpoint {
|
||||
data: Vec<u8>,
|
||||
end_hook: bool,
|
||||
) -> Result<EndpointOutcome, EndpointError> {
|
||||
let local_end_dst_path = dst_path.clone();
|
||||
let (header, message) =
|
||||
self.prepare_data(dst_path, hook_id, procedure_id, data, end_hook)?;
|
||||
|
||||
@@ -213,7 +214,7 @@ impl ProtocolEndpoint {
|
||||
// so fall back to the endpoint's own hook key shape when closing them.
|
||||
let local_hook_key = self
|
||||
.hooks
|
||||
.resolve_active_key(&self.path, hook_id, &self.path)
|
||||
.resolve_active_key(&local_end_dst_path, hook_id, &self.path)
|
||||
.unwrap_or_else(|| HookKey::new(self.path.clone(), hook_id));
|
||||
if self.hooks.mark_local_end(&local_hook_key) {
|
||||
self.hooks.remove_active(&local_hook_key);
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::protocol::{
|
||||
CallMessage, DataMessage, FaultMessage, FrameBytes, FrameError, PacketHeader, ValidationError,
|
||||
};
|
||||
|
||||
use super::super::{CompiledRoutes, HookTable, RouteDecision};
|
||||
use super::super::{CompiledRoutes, HookKey, HookTable, RouteDecision};
|
||||
|
||||
/// Registration state for a direct child endpoint.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
@@ -66,10 +66,12 @@ pub enum LocalEvent {
|
||||
Data {
|
||||
header: PacketHeader,
|
||||
message: DataMessage,
|
||||
hook_key: HookKey,
|
||||
},
|
||||
Fault {
|
||||
header: PacketHeader,
|
||||
message: FaultMessage,
|
||||
hook_key: HookKey,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ impl ProtocolEndpoint {
|
||||
RouteDecision::Local => Ok(EndpointOutcome::event(LocalEvent::Fault {
|
||||
header,
|
||||
message,
|
||||
hook_key: key,
|
||||
})),
|
||||
route => Ok(EndpointOutcome::forward(
|
||||
route,
|
||||
@@ -75,6 +76,7 @@ impl ProtocolEndpoint {
|
||||
message: FaultMessage {
|
||||
fault: ProtocolFault::INVALID_HOOK_PEER,
|
||||
},
|
||||
hook_key: key,
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -87,7 +89,11 @@ impl ProtocolEndpoint {
|
||||
self.hooks.remove_active(&key);
|
||||
}
|
||||
|
||||
Ok(EndpointOutcome::event(LocalEvent::Data { header, message }))
|
||||
Ok(EndpointOutcome::event(LocalEvent::Data {
|
||||
header,
|
||||
message,
|
||||
hook_key: key,
|
||||
}))
|
||||
}
|
||||
|
||||
pub(crate) fn handle_local_fault(
|
||||
@@ -104,6 +110,7 @@ impl ProtocolEndpoint {
|
||||
return Ok(EndpointOutcome::event(LocalEvent::Fault {
|
||||
header,
|
||||
message,
|
||||
hook_key: key,
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -117,6 +124,7 @@ impl ProtocolEndpoint {
|
||||
return Ok(EndpointOutcome::event(LocalEvent::Fault {
|
||||
header,
|
||||
message,
|
||||
hook_key: pending_key,
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ impl ProtocolEndpoint {
|
||||
Ok(EndpointOutcome::event(super::core::LocalEvent::Data {
|
||||
header: response_header,
|
||||
message: response,
|
||||
hook_key: key,
|
||||
}))
|
||||
}
|
||||
route => Ok(EndpointOutcome::forward(
|
||||
|
||||
Reference in New Issue
Block a user