Expand description
§Vine Client
Provides a simplified, thread-safe client for communicating with a Cocoon
sidecar process via gRPC. It manages a shared pool of connections with
robust error handling, automatic reconnection, health checks, and timeout
management.
§Features
- Connection Pool: Thread-safe HashMap of client connections by identifier
- Health Checks: Validates connection status before RPC calls
- Automatic Reconnection: Retries failed connections with exponential backoff
- Request Timeout: Configurable timeout per RPC call
- Retry Logic: Configurable retry attempts for transient failures
- Message Validation: Size limits and format checking for all messages
- Graceful Degradation: Handles Cocoon unavailability gracefully
§Usage Example
use Vine::Client::{ConnectToSideCar, SendRequest};
use serde_json::json;
// Connect to Cocoon
ConnectToSideCar("cocoon-main".to_string(), "127.0.0.1:50052".to_string()).await?;
// Send request
let result = SendRequest(
"cocoon-main",
"GetExtensions".to_string(),
json!({}),
5000, // 5 second timeout
)
.await?;§Error Handling
All operations return Result<T, VineError> with comprehensive error types:
- ClientNotConnected: Sidecar not in connection pool
- RequestTimeout: RPC call exceeded timeout
- RPCError: gRPC transport or status error
- SerializationError: JSON parsing/serialization failure
Modules§
- Config 🔒
- Configuration constants for Vine client behavior
Structs§
- CONNECTION_
METADATA 🔒 - Thread-safe metadata for connection health tracking
- Connection
Metadata 🔒 - Connection metadata tracking health and last activity
- SIDECAR_
CLIENTS 🔒 - Thread-safe pool of Cocoon client connections indexed by identifier
Functions§
- Check
Side CarHealth - Checks the health status of a connected sidecar.
- Connect
ToSide Car - Establishes a gRPC connection to a sidecar process with retry logic.
- Disconnect
From Side Car - Disconnects from a sidecar process and removes it from the connection pool.
- Record
Side 🔒CarFailure - Records a failure for a sidecar connection.
- Send
Notification - Sends a notification to a sidecar without waiting for a response.
- Send
Request - Sends a request to a sidecar and waits for a response.
- Update
Side 🔒CarActivity - Updates the last activity timestamp for a sidecar.
- Validate
Message 🔒Size - Validates message size against maximum allowed.
- try_
connect_ 🔒single - Single connection attempt without retry logic
Type Aliases§
- Cocoon
Client 🔒 - Type alias for the Cocoon gRPC client with Channel transport