Added untested comm impl

This commit is contained in:
2025-12-11 16:25:46 +01:00
parent 4e4dc381ea
commit d211f3127d
14 changed files with 613 additions and 61 deletions

View File

@@ -3,7 +3,7 @@ use std::num::NonZeroU64;
use orchid_api_derive::{Coding, Hierarchy};
use orchid_api_traits::Request;
use crate::{ExtHostReq, HostExtReq};
use crate::{ExtHostNotif, ExtHostReq, HostExtReq};
/// Intern requests sent by the replica to the master. These requests are
/// repeatable.
@@ -71,18 +71,21 @@ pub struct TStr(pub NonZeroU64);
pub struct TStrv(pub NonZeroU64);
/// A request to sweep the replica. The master will not be sweeped until all
/// replicas respond, as it must retain everything the replicas retained
/// replicas respond. For efficiency, replicas should make sure to send the
/// [Sweeped] notif before returning.
#[derive(Clone, Copy, Debug, Coding, Hierarchy)]
#[extends(HostExtReq)]
pub struct Sweep;
impl Request for Sweep {
type Response = Retained;
type Response = ();
}
/// List of keys in this replica that couldn't be sweeped because local
/// datastructures reference their value.
#[derive(Clone, Debug, Coding)]
pub struct Retained {
/// List of keys in this replica that were removed during a sweep. This may have
/// been initiated via a [Sweep] request, but can also be triggered by the
/// replica autonomously.
#[derive(Clone, Debug, Coding, Hierarchy)]
#[extends(ExtHostNotif)]
pub struct Sweeped {
pub strings: Vec<TStr>,
pub vecs: Vec<TStrv>,
}

View File

@@ -28,7 +28,7 @@ use futures::{AsyncRead, AsyncWrite};
use orchid_api_derive::{Coding, Hierarchy};
use orchid_api_traits::{Channel, Decode, Encode, MsgSet, Request, read_exact, write_exact};
use crate::{atom, expr, interner, lexer, logging, parser, system, tree};
use crate::{Sweeped, atom, expr, interner, lexer, logging, parser, system, tree};
static HOST_INTRO: &[u8] = b"Orchid host, binary API v0\n";
pub struct HostHeader {
@@ -99,6 +99,7 @@ pub enum ExtHostReq {
pub enum ExtHostNotif {
ExprNotif(expr::ExprNotif),
Log(logging::Log),
Sweeped(Sweeped),
}
pub struct ExtHostChannel;