lxy 0.1.1

A convenient async http and RPC framework in Rust
Documentation
use serde::Deserialize;

use crate::config::Config;

/// Configuration for the gRPC server
#[derive(Debug, Deserialize, Clone)]
pub struct GrpcConfig {
  /// Host address to bind the gRPC server to
  #[serde(default = "default_host")]
  pub host: String,

  /// Port to bind the gRPC server to
  #[serde(default = "default_port")]
  pub port: u16,

  /// Maximum message size in bytes
  #[serde(default = "default_max_message_size")]
  pub max_message_size: usize,

  /// Maximum number of concurrent gRPC streams
  #[serde(default)]
  pub concurrency_limit: Option<usize>,
}

fn default_host() -> String {
  "127.0.0.1".into()
}

fn default_port() -> u16 {
  50051
}

fn default_max_message_size() -> usize {
  4 * 1024 * 1024 // 4MB
}

impl Default for GrpcConfig {
  fn default() -> Self {
    Self {
      host: default_host(),
      port: default_port(),
      max_message_size: default_max_message_size(),
      concurrency_limit: None,
    }
  }
}

impl Config for GrpcConfig {
  fn name() -> &'static str {
    "grpc"
  }
}