Module AirClient

Module AirClient 

Source
Expand description

§AirClient

gRPC client wrapper for the Air daemon service, providing Mountain with access to cloud-based backend services including updates, authentication, file indexing, and system monitoring.

IMPORTANT: The gRPC client is wrapped in Arc<Mutex<>> to enable safe concurrent access from multiple threads, as tonic’s client methods require mutable access.

§RESPONSIBILITIES

  • Connection Management: Manage gRPC connection lifecycle to Air service
  • Service Methods: Implement all Air service RPC methods
  • Error Translation: Convert tonic/transport errors to CommonError
  • Connection Retry: (Optional) Provide automatic retry with backoff
  • Health Checking: Monitor Air service availability

§ARCHITECTURAL ROLE

AirClient serves as the primary interface between Mountain and the Air backend service:

Mountain (Frontend) ──► AirClient ──► gRPC ──► Air Daemon (Backend)

§Position in Mountain

  • Communication module for Air integration
  • Part of the service management layer
  • Features-gated behind AirIntegration feature flag

§IMPLEMENTATION

This implementation uses the generated gRPC client from the Air library:

  • AirLibrary::Vine::Generated::air_service_client::AirServiceClient

§CONFIGURATION

  • Default Address: [::1]:50053 (configurable via constructor)
  • Transport: gRPC over TCP/IP with optional TLS
  • Connection Pooling: (TODO) Implement for multiple concurrent requests

§ERROR HANDLING

All methods return Result<T, CommonError> with appropriate error types:

  • IPCError: gRPC communication failures
  • SerializationError: Message encoding/decoding failures
  • Unknown: Uncategorized errors

§THREAD SAFETY

  • AirClient is Cloneable and can be shared across threads via Arc<AirClient>
  • The underlying tonic client is thread-safe
  • All public methods are safe to call from multiple threads

§PERFORMANCE CONSIDERATIONS

  • Connection establishment is lazy (deferred until first use)
  • (TODO) Implement connection pooling for high-throughput scenarios
  • (TODO) Add request caching for frequently accessed data
  • (TODO) Implement request timeout configuration

§TODO

High Priority:

  • Add connection retry with exponential backoff
  • Implement proper connection pooling

Medium Priority:

  • Add request/response logging for debugging
  • Implement connection health monitoring
  • Add metrics collection for RPC calls

§MODULE CONTENTS

Structs§

AirClient
Air gRPC client wrapper that handles connection to the Air daemon service. This provides a clean interface for Mountain to interact with Air’s capabilities including update management, authentication, file indexing, and system monitoring.
AirMetrics
Metrics from the Air daemon.
AirStatus
Status of the Air daemon.
DownloadStream
Wrapper for an asynchronous download stream.
DownloadStreamChunk
Chunk of data from a streaming download.
ExtendedFileInfo
Extended file information.
FileInfo
Information about a downloaded file.
FileResult
Result of a file search.
IndexInfo
Information about file indexing.
ResourceUsage
Resource usage information.
UpdateInfo
Information about an available update.

Constants§

DEFAULT_AIR_SERVER_ADDRESS
Default gRPC server address for the Air daemon.

Traits§

IntoRequestExt 🔒
Helper trait for converting types to tonic::Request