Skip to main content

onlyne_client/session/
dispatch.rs

1// The parts below open with `use super::*`, so this module keeps the imports the
2// single-file version shared with them, and re-exports exactly the names it
3// exported publicly before the split. No logic lives here.
4use crate::backend::{SessionBackend, SessionRef, SpawnSpec};
5use crate::reconcile::{
6    Bridge, apply_persist, feed_agent_gone, feed_created, feed_dispatched, feed_intent_receipt,
7    feed_ready, feed_resource_closed, feed_resumed, feed_suspended, settle, stored_observation,
8};
9use crate::runtime::intent::stamp_op_id;
10use crate::runtime::runloop::ClientInit;
11use crate::session::handoff;
12use anyhow::{Context, Result, anyhow};
13use onlyne_adapter::AdapterIo;
14use onlyne_config::layout::RoleWorkspace;
15use onlyne_net::conn::{ClientConn, ConnReadiness, dial};
16use onlyne_net::{ConnSettings, KeyPair, NetError};
17use onlyne_proto::{
18    AckArgs, AdapterMsg, AgentPhase, AssignArgs, Body, Capability, Causality, ClientOp, ControlOp,
19    DeliveryPhase, Envelope, Frame, HandshakeArgs, HostOp, Lifecycle, LiveSession, MsgKind,
20    Outcome, PROTOCOL_VERSION, Principal, RecoveryPhase, RecycleArgs, Report, ResBody,
21    ResourcePhase, SessionProjection, Welcome, new_envelope,
22};
23use onlyne_proto::{
24    IgnoredReason, LifecycleEvent, Observation, TaskState, Verdict, Version, project,
25};
26use onlyne_store::ClientStore;
27use onlyne_store::session::{SessionLedger, SessionRecord};
28use parking_lot::Mutex;
29use std::collections::{BTreeMap, BTreeSet, HashMap};
30use std::path::{Path, PathBuf};
31use std::pin::Pin;
32use std::sync::Arc;
33use std::sync::atomic::{AtomicBool, Ordering};
34use std::time::{Duration, Instant};
35use tokio::sync::broadcast;
36
37mod delivery;
38mod env;
39mod guards;
40mod idle;
41mod outbound;
42mod projection;
43mod reports;
44mod retire;
45mod scope;
46mod settle;
47mod slots;
48mod state;
49mod transport;
50mod turn_end;
51
52pub use delivery::{ReadyNotice, dispatch, on_ready};
53pub use env::{
54    HEARTBEAT_INTERVAL, HEARTBEAT_SILENCE_MARGIN, REQUEST_TIMEOUT, missing_capability, plugin_gap,
55};
56pub use outbound::{ClientLink, Outbox, send_frame};
57pub use projection::{
58    note_intent_receipt, note_verdict, projection_of, sync_frame, sync_session, task_outcome_of,
59    task_state_of, with_cluster,
60};
61pub use reports::{on_control, on_plugin_report};
62pub use retire::{SESSION_DEAD, close_all, on_recycled};
63pub use settle::{SETTLE_WITHOUT_TURN, SettleAuthority, on_out};
64pub use state::{
65    CONTROL_SETTLE_BOUND, ControlNote, ControlWord, DispatchState, FrameGuard, SessionSlot,
66};
67pub use turn_end::on_turn_end;