Mountain/Vine/Server/
mod.rs

1//! # Vine gRPC Server Module
2//!
3//! This module contains the implementation for the Mountain gRPC server. It is
4//! responsible for listening for incoming connections from sidecars like
5//! `Cocoon`, handling RPC requests, and dispatching them into the Mountain
6//! application logic.
7//!
8//! ## Architecture
9//!
10//! The Vine server implements two complementary gRPC services:
11//!
12//! ### MountainService (Listens on one port)
13//! - **ProcessCocoonRequest**: Handles request-response calls from Cocoon
14//! - **SendCocoonNotification**: Processes fire-and-forget notifications from
15//!   Cocoon
16//! - **CancelOperation**: Cancels long-running operations requested by Cocoon
17//!
18//! ### CocoonService (Listens on separate port)
19//! - **ProcessMountainRequest**: Handles request-response calls from Mountain
20//!   to Cocoon
21//! - **SendMountainNotification**: Processes notifications from Mountain to
22//!   Cocoon
23//! - **CancelOperation**: Cancels operations in Cocoon
24//!
25//! ## Lifecycle Management
26//!
27//! 1. **Initialization**: Servers are spawned as background tasks via
28//!    `Initialize::Initialize`
29//! 2. **Service Registration**: gRPC services are registered with tonic's
30//!    Server builder
31//! 3. **Request Handling**: Each RPC call is dispatched to appropriate handlers
32//! 4. **Graceful Shutdown**: Servers terminate when tokio runtime is shut down
33//!
34//! ## Data Flow
35//!
36//! ```text
37//! Cocoon Sidecar                          Mountain Extension Host
38//!      │                                          │
39//!      │  ┌──────────────────────────────────►    │
40//!      │  │ MountainService::ProcessCocoonRequest │
41//!      │  │ (extensions, queries, state)          │
42//!      │  ◄───────────────────────────────────    │
43//!      │                                          │
44//!      │  ┌──────────────────────────────────►    │
45//!      │  │ MountainService::SendCocoonNotification
46//!      │  │ (status updates, events)              │
47//!      │  ◄───────────────────────────────────    │
48//!      │                                          │
49//!      │  ◄────────────────────────────────────── │
50//!      │  │ CocoonService::ProcessMountainRequest │
51//!      │  │ (Webview operations, IPC)             │
52//!      │  ┌──────────────────────────────────►    │
53//!      │                                          │
54//!      │  ◄────────────────────────────────────── │
55//!      │  │ CocoonService::SendMountainNotification
56//!      │  │ (config changes, commands)             │
57//!      │  ┌──────────────────────────────────►    │
58//!      │                                          │
59//! ```
60//!
61//! ## Error Handling
62//!
63//! - Request validation before processing
64//! - Comprehensive error conversion to tonic::Status
65//! - Detailed logging of all errors
66//! - Graceful error responses to clients
67//!
68//! ## Security Considerations
69//!
70//! - Request size limits (4MB default)
71//! - Method whitelisting (prevents arbitrary method calls)
72//! - Parameter validation before processing
73//! - Safe error messages (no sensitive data leakage)
74//!
75//! ## Modules
76//!
77//! - [`Initialize`]: Server initialization and startup logic
78//! - [`MountainVinegRPCService`]: Implementation of MountainService (Cocoon →
79//!   Mountain)
80//! - `CocoonServiceImpl`: Implementation of CocoonService (Mountain → Cocoon)
81
82#![allow(non_snake_case)]
83
84pub mod Initialize;
85
86pub mod MountainVinegRPCService;