Skip to main content

Vine/Server/
Constants.rs

1//! Default configuration constants for Vine gRPC servers.
2//!
3//! Canonical home for the values every Vine bind site shares: default
4//! ports, connection timeout, max concurrent connection budget, max message
5//! size. Consumers (Mountain's `MountainVinegRPCService`, Air's
6//! `AirVinegRPCService`, any Rust-side Cocoon client) reference these
7//! constants instead of redefining them.
8
9use std::time::Duration;
10
11/// Default port for the MountainService gRPC server.
12///
13/// Mountain binds this port and listens for connections from Cocoon and Air.
14pub const DEFAULT_MOUNTAIN_PORT:u16 = 50051;
15
16/// Default port for the CocoonService gRPC server.
17///
18/// Cocoon binds this port; Mountain connects as a client.
19pub const DEFAULT_COCOON_PORT:u16 = 50052;
20
21/// Default port for the AirService gRPC server.
22///
23/// Air binds this port; Mountain (and external clients) connect as clients.
24pub const DEFAULT_AIR_PORT:u16 = 50053;
25
26/// Maximum concurrent connections per server. Tonic does not directly enforce
27/// this today; the constant is exposed so the embedder can apply it via
28/// `tower::limit::ConcurrencyLimitLayer` if needed.
29pub const MAX_CONNECTIONS:usize = 100;
30
31/// Default connection timeout used by the bind helper when configuring the
32/// underlying tonic Server.
33pub const CONNECTION_TIMEOUT:Duration = Duration::from_secs(30);
34
35/// Default message size limit (4 MB).
36///
37/// Mirrors tonic's own default and the value enforced on the client side
38/// via `crate::Client::Shared::MAX_MESSAGE_SIZE_BYTES`. Apply this to every
39/// service wrapper via `.max_decoding_message_size()` /
40/// `.max_encoding_message_size()` before `add_service` so unary calls fail
41/// fast for oversized payloads.
42pub const MAX_MESSAGE_SIZE:usize = 4 * 1024 * 1024;