feat(call): implement CallConnection with imported-ops overlay and call/subscribe/abort (task: call/protocol/call-connection)
Implement CallConnection in protocol/connection.rs with Layer 2 imported-ops overlay (Arc<RwLock<HashMap>>), register_imported/register_imported_all, overlay_env() returning an OperationEnv that dispatches to imported ops, and call()/subscribe()/abort() methods that open a stream, send call.requested, register in PendingRequestMap, spawn a stream reader, and correlate responses by ID. Connection drop drops the overlay. Exposed MockConnection + Connection::from_mock in alknet-core for cross-crate testing. 9 new connection tests (102 total in alknet-call). Refs: docs/architecture/crates/call/call-protocol.md Implements: ADR-012, ADR-017, ADR-024
This commit is contained in:
@@ -368,7 +368,7 @@ enum ConnectionKind {
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) trait MockConnection: Send + Sync {
|
||||
pub trait MockConnection: Send + Sync {
|
||||
fn remote_alpn(&self) -> &[u8];
|
||||
fn remote_addr(&self) -> Option<SocketAddr>;
|
||||
fn close(&self, code: u32, reason: &str);
|
||||
@@ -406,7 +406,7 @@ impl Connection {
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn from_mock(mock: Arc<dyn MockConnection + Send + Sync>) -> Self {
|
||||
pub fn from_mock(mock: Arc<dyn MockConnection + Send + Sync>) -> Self {
|
||||
let alpn = mock.remote_alpn().to_vec();
|
||||
Self {
|
||||
kind: ConnectionKind::Mock(mock),
|
||||
@@ -523,6 +523,7 @@ mod tests {
|
||||
closed: std::sync::Mutex<Option<(u32, String)>>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl MockConnection for MockConn {
|
||||
fn remote_alpn(&self) -> &[u8] {
|
||||
self.alpn
|
||||
|
||||
Reference in New Issue
Block a user