Skip to main content

running_process/broker/server/
mod.rs

1//! Broker server foundation for `running-process-broker-v1`.
2//!
3//! Phase 4 (#235) grows this module into the pipe accept loop, service
4//! definition loader, backend registry, admin verbs, and perf guard.
5//! The first slice keeps the core Hello validation and negotiation
6//! logic testable without binding sockets or spawning backends.
7
8pub mod admin;
9pub mod backend_endpoint_allocator;
10pub mod backend_launcher;
11pub mod backend_registry;
12pub mod broadcast;
13pub mod combined_service_def_loader;
14pub mod connection;
15pub mod control_socket;
16#[doc(hidden)]
17pub mod deadline_stream;
18pub mod fd_pressure;
19pub mod handoff;
20pub mod handoff_serve;
21pub mod hello_handler;
22pub mod hello_router;
23pub mod idle_coord;
24pub mod instance;
25pub mod metrics;
26pub mod perf_guard;
27pub mod recovery;
28pub mod serve;
29#[path = "service_def_loader_compat.rs"]
30pub mod service_def_loader;
31/// Async v2 broker SESSION serve path (soldr#2365) — the strangler-fig async
32/// twin of the sync control-socket loop. Gated on `client-async`: it needs a
33/// tokio runtime and the async `session_relay`. See the module docs for why it
34/// is not yet wired to the broker binary (async peer creds are unresolved).
35#[cfg(feature = "client-async")]
36pub mod session_serve_async;
37/// zackees/soldr#2360/#2363 — composite broker/daemon session token
38/// authority. Wired into `hello_handler` via
39/// `HelloHandler::with_session_token_authority` — see the module docs.
40pub mod session_token;
41pub mod singleton_bind;
42pub mod spawn_coordinator;
43pub mod spawn_wait;
44pub mod trace_context;
45pub mod version_allow_list;
46
47pub use admin::{
48    handle_admin_connection, serve_one_admin_socket, AdminBackend, AdminConnectionError,
49    AdminFrameError, AdminInodePressure, AdminSnapshot, AdminSpawnBudget, ADMIN_PAYLOAD_PROTOCOL,
50    ADMIN_SCHEMA_VERSION,
51};
52pub use backend_endpoint_allocator::{
53    BackendEndpointAllocator, BackendEndpointAllocatorError, DEFAULT_BACKEND_ENDPOINT_ATTEMPTS,
54};
55pub use backend_launcher::{
56    BackendLaunchError, BackendLaunchRequest, BackendLauncher, CommandBackendLauncher,
57    BACKEND_ENV_ENDPOINT_NAMESPACE, BACKEND_ENV_ENDPOINT_PATH, BACKEND_ENV_INSTANCE,
58    BACKEND_ENV_SERVICE_NAME, BACKEND_ENV_SERVICE_VERSION, BACKEND_ENV_TRACEPARENT,
59    BACKEND_ENV_TRACESTATE,
60};
61pub use backend_registry::{BackendKey, BackendRegistry};
62pub use broadcast::{
63    BroadcastAck, BroadcastBackend, BroadcastBackendResponse, BroadcastFailure,
64    BroadcastFailureReason, BroadcastOperation, BroadcastPolicy, BroadcastResult, BroadcastTimeout,
65    LifecycleBroadcastModel, QuiesceReason, DEFAULT_BROADCAST_ACK_TIMEOUT,
66};
67pub use combined_service_def_loader::{
68    service_definition_v2_to_v1, CombinedServiceDefinitionLoader, ServiceDefinitionSource,
69};
70pub use connection::{
71    handle_hello_connection, handle_hello_connection_with,
72    handle_hello_connection_with_peer_policy, local_socket_name, peer_identity_from_stream,
73    serve_local_socket_connections, serve_local_socket_connections_with,
74    serve_local_socket_connections_with_peer_policy, serve_local_socket_connections_with_policy,
75    serve_one_local_socket, serve_one_local_socket_with, serve_one_local_socket_with_peer_policy,
76    BrokerConnectionError, HelloResponder, PeerCredentialPolicy,
77};
78pub use control_socket::{
79    handle_control_connection_with_peer_policy,
80    handle_control_connection_with_peer_policy_and_fd_guard,
81    serve_control_socket_connections_with_limit_and_policy,
82    serve_control_socket_connections_with_limit_policy_and_post_hello,
83    serve_control_socket_connections_with_limit_policy_post_hello_and_fd_guard,
84    serve_control_socket_connections_with_policy, ControlSocketConnectionLimit, ControlSocketError,
85    ControlSocketReply,
86};
87pub use fd_pressure::{
88    fd_exhaustion_error_for_tests, is_fd_exhaustion_error, FdPressureConfig, FdPressureDecision,
89    FdPressureGuard, DEFAULT_FD_PRESSURE_RECOVERY_ACCEPTS, DEFAULT_FD_PRESSURE_RETRY_AFTER_MS,
90};
91pub use handoff::{
92    handoff_ready_frame, AcknowledgedHandoff, ExpiredHandoff, HandoffAckError, HandoffAckRegistry,
93    HandoffAttemptDecision, HandoffAttemptFailure, HandoffAttemptInputs, HandoffFallbackDecision,
94    HandoffFallbackPolicy, HandoffFallbackReason, HandoffFallbackState, HandoffToken,
95    HandoffTokenError, HandoffTokenStore, HandoffTokenStoreConfig, PendingHandoffBackend,
96    PendingHandoffOverflow, PendingHandoffQueue, PendingHandoffQueueConfig,
97    DEFAULT_HANDOFF_ACK_DEADLINE, DEFAULT_HANDOFF_FAILED_ATTEMPTS_PER_WINDOW,
98    DEFAULT_HANDOFF_FAILED_ATTEMPT_WINDOW, DEFAULT_HANDOFF_TOKEN_COLLISION_ATTEMPTS,
99    DEFAULT_HANDOFF_TOKEN_TTL, DEFAULT_MAX_PENDING_HANDOFFS, DEFAULT_MAX_PENDING_HANDOFF_TOKENS,
100    DEFAULT_PENDING_HANDOFF_TTL, HANDOFF_TOKEN_BYTES,
101};
102pub use handoff_serve::{
103    complete_negotiated_handoff, try_complete_negotiated_handoff, try_transfer_negotiated_handoff,
104    ServeHandoffContext,
105};
106pub use hello_handler::{
107    HelloHandler, HelloHandlerError, HelloRequest, PeerIdentity, RegisteredBackend,
108};
109pub use hello_router::HelloRouter;
110pub use idle_coord::{
111    BackendIdleCoordinator, BackendIdleDue, BackendIdlePolicy, DEFAULT_BACKEND_IDLE_TIMEOUT,
112};
113pub use instance::{BrokerInstanceError, BrokerInstanceKey};
114pub use perf_guard::{
115    enforce_hello_latency_budget, summarize_hello_latencies, HelloLatencySummary, PerfGuardError,
116    HELLO_P50_BUDGET, HELLO_P99_BUDGET, HELLO_PERF_GUARD_ENV, HELLO_PERF_SAMPLE_COUNT,
117};
118pub use recovery::{
119    BackendRecoveryDecision, BackendRecoveryPolicy, BackendRecoveryRefusalReason,
120    BackendRecoveryState, DEFAULT_RECOVERY_BUDGET_WINDOW, DEFAULT_RECOVERY_RETRY_BACKOFF,
121};
122pub use serve::{
123    build_hello_handler, serve_launching_backends, serve_launching_backends_with_launcher,
124    serve_registered_backend, BrokerLaunchServeConfig, BrokerServeConfig, BrokerServeError,
125};
126pub use service_def_loader::{
127    ensure_service_definition_dir, service_definition_dir, service_definition_path,
128    validate_service_definition_for_service, write_service_definition, ServiceDefinitionError,
129    ServiceDefinitionLoader, SERVICE_DEF_DIR_ENV, SERVICE_DEF_EXTENSION,
130};
131pub use spawn_coordinator::{
132    acquire_spawn_lock, SpawnBeginError, SpawnBudgetConfig, SpawnBudgetSnapshot, SpawnCoordinator,
133    SpawnLockError, SpawnLockFileIdentity, SpawnLockGuard, SpawnOutcome, SpawnPermit,
134    DEFAULT_SPAWN_ATTEMPTS_PER_WINDOW, DEFAULT_SPAWN_BUDGET_WINDOW,
135};
136pub use spawn_wait::{
137    SpawnWaitDecision, SpawnWaitPolicy, SpawnWaitProbe, DEFAULT_SPAWN_WAIT_HARD_CEILING,
138    SPAWN_WAIT_BACKOFF_SEQUENCE,
139};
140pub use trace_context::TraceContext;
141pub use version_allow_list::{check_version_allowed, VersionPolicyBlock};