use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct GateConfig {
pub path: String,
pub method: String,
}
impl GateConfig {
pub fn new(path: impl Into<String>) -> Self {
Self {
path: path.into(),
method: "POST".into(),
}
}
pub fn with_method(path: impl Into<String>, method: impl Into<String>) -> Self {
Self {
path: path.into(),
method: method.into(),
}
}
}
#[derive(Debug, Clone)]
pub struct RuneConfig {
pub name: String,
pub version: String,
pub description: String,
pub input_schema: Option<serde_json::Value>,
pub output_schema: Option<serde_json::Value>,
pub supports_stream: bool,
pub gate: Option<GateConfig>,
pub priority: i32,
}
impl Default for RuneConfig {
fn default() -> Self {
Self {
name: String::new(),
version: "0.0.0".into(),
description: String::new(),
input_schema: None,
output_schema: None,
supports_stream: false,
gate: None,
priority: 0,
}
}
}
impl RuneConfig {
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
..Default::default()
}
}
}
#[derive(Debug, Clone)]
pub struct FileAttachment {
pub filename: String,
pub data: bytes::Bytes,
pub mime_type: String,
}
#[derive(Debug, Clone)]
pub struct CasterConfig {
pub runtime: String,
pub key: Option<String>,
pub caster_id: Option<String>,
pub max_concurrent: u32,
pub heartbeat_interval_secs: f64,
pub reconnect_base_delay_secs: f64,
pub reconnect_max_delay_secs: f64,
pub labels: HashMap<String, String>,
pub scale_policy: Option<ScalePolicy>,
pub load_report: Option<LoadReport>,
}
impl Default for CasterConfig {
fn default() -> Self {
Self {
runtime: "localhost:50070".into(),
key: None,
caster_id: None,
max_concurrent: 10,
heartbeat_interval_secs: 10.0,
reconnect_base_delay_secs: 1.0,
reconnect_max_delay_secs: 30.0,
labels: HashMap::new(),
scale_policy: None,
load_report: None,
}
}
}
#[derive(Debug, Clone)]
pub struct ScalePolicy {
pub group: String,
pub scale_up_threshold: f64,
pub scale_down_threshold: f64,
pub sustained_secs: u64,
pub min_replicas: u32,
pub max_replicas: u32,
pub spawn_command: String,
pub shutdown_signal: String,
}
impl ScalePolicy {
pub fn new(group: impl Into<String>, spawn_command: impl Into<String>) -> Self {
Self {
group: group.into(),
spawn_command: spawn_command.into(),
..Default::default()
}
}
}
impl Default for ScalePolicy {
fn default() -> Self {
Self {
group: String::new(),
scale_up_threshold: 0.8,
scale_down_threshold: 0.2,
sustained_secs: 30,
min_replicas: 1,
max_replicas: 1,
spawn_command: String::new(),
shutdown_signal: "SIGTERM".into(),
}
}
}
#[derive(Debug, Clone, Default)]
pub struct LoadReport {
pub pressure: Option<f64>,
pub metrics: HashMap<String, f64>,
}