pub struct ConnectBridge { /* private fields */ }Expand description
Routes inbound platform messages to bamboo sessions, enforces the per-platform allow-list + dedup, and serializes execution per chat behind a busy lock + FIFO queue.
Implementations§
Source§impl ConnectBridge
impl ConnectBridge
Sourcepub fn new(ctx: ConnectContext, map_path: Option<PathBuf>) -> Self
pub fn new(ctx: ConnectContext, map_path: Option<PathBuf>) -> Self
Production constructor: wires up approvals::EngineResponder (the
in-proc respond+resume path) automatically. See Self::with_responder
for injecting a fake in tests.
Sourcepub fn with_responder(
ctx: ConnectContext,
map_path: Option<PathBuf>,
responder: Arc<dyn Responder>,
) -> Self
pub fn with_responder( ctx: ConnectContext, map_path: Option<PathBuf>, responder: Arc<dyn Responder>, ) -> Self
Test/advanced constructor: inject a Responder seam instead of the
production EngineResponder (issue #458: “Design a small Responder
seam on the bridge so tests inject a fake instead of full AppState”).
Sourcepub async fn load_session_map(&self)
pub async fn load_session_map(&self)
Loads the persisted chat -> session map from disk, if a map_path
was configured. Tolerates a missing or corrupt file (starts empty,
logging a warning on corruption) — a fresh/lost map degrades to
“every chat starts a new session,” never a hard failure.
pub async fn session_id_for_key(&self, key: &str) -> Option<String>
Sourcepub async fn handle_inbound(
self: Arc<Self>,
platform: Arc<dyn Platform>,
allow_from: Vec<String>,
msg: InboundMessage,
)
pub async fn handle_inbound( self: Arc<Self>, platform: Arc<dyn Platform>, allow_from: Vec<String>, msg: InboundMessage, )
Entry point for every inbound platform message. Enforces allow-list +
dedup, answers /stop and /status immediately (bypassing the busy
queue — a queued /stop could never reach a busy chat), and otherwise
either runs the message right away or queues it behind the chat’s
current run.
Takes self: Arc<Self> (not &self) so it can hand the bridge off to
a detached tokio::spawn for the actual (potentially long-running)
execution — this method itself returns as soon as the message is
either answered inline or queued, so one slow chat can never block
another chat’s inbound dispatch loop.
Sourcepub async fn handle_callback(
self: Arc<Self>,
platform: Arc<dyn Platform>,
allow_from: Vec<String>,
callback: CallbackQuery,
)
pub async fn handle_callback( self: Arc<Self>, platform: Arc<dyn Platform>, allow_from: Vec<String>, callback: CallbackQuery, )
Entry point for every inbound button-press callback (issue #458).
Unlike text messages, a callback NEVER queues and NEVER starts a run —
it can only ever resolve (or fail to resolve) the chat’s parked ask.
Per the design constraint, the platform is ALWAYS acked
(answer_callback), even for a stale/forged/non-matching one, and a
non-match is dropped silently rather than ever being forwarded as
user text.