Expand description
§Vine::Client
Client-side gRPC wrappers for embedders that need to call Vine services (Air talking to Mountain, Cocoon-Rust talking to Mountain, …). One entry-point per file:
MarkShutdown::Fn/IsShuttingDown::Fn- process-wide flag.NotificationFrame::Struct- broadcast payload.SubscribeNotifications::Fn/SubscriberCount::Fn- fan-out access.ConnectToSideCar::Fn/DisconnectFromSideCar::Fn- pool lifecycle. Driven byTryConnectSingle::Fn(single attempt).IsClientConnected::Fn/WaitForClientConnection::Fn- boot-race-friendly readiness checks.CheckSideCarHealth::Fn- pool + metadata health summary.SendRequest::Fn/SendNotification::Fn- wire dispatch with optional streaming-multiplexer fast path underLAND_VINE_STREAMING=1when themultiplexercargo feature is enabled.PublishNotification::Fn(private) and [PublishNotificationFromMux::Fn] (pub(crate)) - broadcast publishers.Shared- module-private state (statics, helpers, constants).
§Behaviours
- 3-attempt exponential backoff (50 ms / 100 ms / 200 ms base schedule) in
ConnectToSideCar::Fn. Arc<Notify>connection-ready wake-up (no polling) inWaitForClientConnection::Fn.- 5 000 ms unary default timeout, bounded by
crate::DefaultRequestTimeoutMsat 15 000 ms; per-call override onSendRequest::Fn. - Atomic-counter request IDs (
AtomicU64, noSystemTimesyscall) inSendRequest::Fn. - h2 transport tuning (4 MB stream / 16 MB connection windows;
LAND_TONIC_TUNED=0to disable) inTryConnectSingle::Fn.
Modules§
- Check
Side CarHealth - Health check: connection exists in the pool, last activity within
HEALTH_CHECK_INTERVAL_MS, and failure count below the retry threshold. - Connect
ToSide Car - Establish a gRPC connection to a Cocoon sidecar with exponential
back-off retry. On success initialises the per-connection metadata
tracked by
Shared::CONNECTION_METADATA. - Disconnect
From Side Car - Disconnect from a sidecar process. Removes the entry from both the connection pool and the metadata tracker.
- IsClient
Connected - Whether the named sidecar currently has a live entry in the
connection pool. Cheap read of the shared map; no RPC issued. Useful
for boot-race callers that need to know whether
SendRequestwould short-circuit before paying the serialization + lock-acquire cost. - IsShutting
Down - Whether the Vine client has been marked shutting down.
- Mark
Shutdown - Flip the global Vine-client shutdown flag. Embedders call this
immediately before SIGKILL’ing the sidecar so any inflight notification
attempted after the kill window returns silently with
Ok(())instead of logging aConnection refusederror. - Notification
Frame - One observed notification frame fanned out from
SendNotification(or, once the streaming-channel multiplexer is live, fromMultiplexer). Subscribers consume frames from the broadcast channel managed byShared::NOTIFICATION_BROADCAST. - Publish
Notification 🔒 - Internal: publish a notification to the broadcast. Called from
SendNotification::Fnafter the wire send succeeds, and from the streaming multiplexer once it lands.try_sendsemantics - no awaiting, no failure surfaced (a slow subscriber must not stall the producer). - Send
Notification - Fire-and-forget notification to a sidecar. No response, no per-call
timeout. Prefers the streaming multiplexer under
LAND_VINE_STREAMING=1when themultiplexercargo feature is enabled; falls through to unary on any failure. After a successful wire send, fans out viaPublishNotification::Fnso broadcast subscribers (Effect-TS fibers, OTel emitters, future Mist-WS bridge, dev log) can observe the same flow concurrently. - Send
Request - Send a request and await a response. Validates method-name length and
message size, prefers the streaming multiplexer when
LAND_VINE_STREAMING=1is on and themultiplexercargo feature is enabled (falls through to unary on any failure except the authoritative streaming-path timeout), enforces a per-call timeout viatokio::time::timeout, and updates per-connection activity / failure metadata on completion. - Shared
- Module-private state for the Vine client: connection pool, per- connection metadata, the broadcast fan-out, the shutdown flag, plus the constants and message-size validator every entry-point shares.
- Subscribe
Notifications - Subscribe to the global notification fan-out. Each call returns a fresh receiver that observes every notification fanned out AFTER subscribe time (broadcast semantics; no historical replay). Drop the receiver to unsubscribe.
- Subscriber
Count - Number of currently-active broadcast subscribers. Diagnostic; useful for validating that subscribers haven’t leaked.
- TryConnect
Single - Single connection attempt without retry logic. Tunes h2 transport
windows for loopback-to-Cocoon traffic (4 MB stream / 16 MB connection)
so a single rust-analyzer diagnostic emit (200-500 KB) doesn’t cause
WINDOW_UPDATEping-pong. - Wait
ForClient Connection - Await Cocoon’s gRPC connection without polling.
GetConnectionNotifyreturns a sharedtokio::sync::NotifythatConnectToSideCarfires once the handshake succeeds;WaitForClientConnectionsimply awaits it undertokio::time::timeout. If the sidecar is already connected when we enter (typical for the second-and-later callers)notified()returns immediately becausenotify_waitershas already fired.