feat(call): implement CallAdapter (ProtocolHandler for alknet/call) with stream handling, identity resolution, root context construction (task: call/protocol/call-adapter)
- CallAdapter struct with registry, identity_provider, session_source, default_timeout (30s) - new(), with_session_source(), with_timeout() constructors - SessionOverlaySource trait defined (overlay_for) for agent-crate integration - ProtocolHandler::alpn() returns b"alknet/call" - handle() sets connection identity from AuthContext, spawns accept_bi loop, reads EventEnvelope frames via FrameFramedReader, dispatches call.requested to the operation registry, writes ResponseEnvelope as EventEnvelope via FrameFramedWriter - Per-request identity resolution: AuthContext.identity used by default, auth_token in payload overrides via IdentityProvider::resolve_from_token(); resolution failure falls back to connection-level identity - build_root_context sets internal: false, deadline (now + default_timeout), capabilities and scoped_env from registration bundle, parent_request_id: None - compose_root_env builds CompositeOperationEnv (Layer 0 curated base + Layer 2 connection overlay + optional Layer 1 session overlay) - operationId leading slash stripped before registry lookup - ResponseEnvelope -> EventEnvelope conversion (Ok -> call.responded, Err -> call.error) - PendingRequestMap sweeper runs every 10s, evicts expired wire entries - Connection drop: fail_all pending with INTERNAL "connection closed", return Ok(()) - Stream reset: FrameFramedReader error closes stream; other streams unaffected - Handler panic: stream task isolated via tokio::spawn, sweep cleans entry - Tests: alpn, constructors, slash strip, identity resolution (override/fallback), root context (internal=false, deadline, capabilities, scoped_env), env composition (layers aggregate, session overlay), dispatch round-trip, internal op from wire -> NOT_FOUND, ACL denied -> FORBIDDEN, auth_token overrides connection identity, unknown op -> NOT_FOUND, no-slash resolution, ResponseEnvelope -> EventEnvelope conversions
This commit is contained in:
@@ -50,6 +50,10 @@ impl CallConnection {
|
||||
&self.connection
|
||||
}
|
||||
|
||||
pub(crate) fn pending(&self) -> &Arc<Mutex<PendingRequestMap>> {
|
||||
&self.pending
|
||||
}
|
||||
|
||||
pub fn register_imported(&self, registration: HandlerRegistration) {
|
||||
let name = registration.spec.name.clone();
|
||||
self.imported_operations.write().insert(name, registration);
|
||||
|
||||
Reference in New Issue
Block a user