1use std::collections::HashMap;
4
5#[derive(Debug, Clone)]
7pub struct GateConfig {
8 pub path: String,
10 pub method: String,
12}
13
14impl GateConfig {
15 pub fn new(path: impl Into<String>) -> Self {
17 Self {
18 path: path.into(),
19 method: "POST".into(),
20 }
21 }
22
23 pub fn with_method(path: impl Into<String>, method: impl Into<String>) -> Self {
25 Self {
26 path: path.into(),
27 method: method.into(),
28 }
29 }
30}
31
32#[derive(Debug, Clone)]
34pub struct RuneConfig {
35 pub name: String,
37 pub version: String,
39 pub description: String,
41 pub input_schema: Option<serde_json::Value>,
43 pub output_schema: Option<serde_json::Value>,
45 pub supports_stream: bool,
47 pub gate: Option<GateConfig>,
49 pub priority: i32,
51}
52
53impl Default for RuneConfig {
54 fn default() -> Self {
55 Self {
56 name: String::new(),
57 version: "0.0.0".into(),
58 description: String::new(),
59 input_schema: None,
60 output_schema: None,
61 supports_stream: false,
62 gate: None,
63 priority: 0,
64 }
65 }
66}
67
68impl RuneConfig {
69 pub fn new(name: impl Into<String>) -> Self {
71 Self {
72 name: name.into(),
73 ..Default::default()
74 }
75 }
76}
77
78#[derive(Debug, Clone)]
80pub struct FileAttachment {
81 pub filename: String,
83 pub data: bytes::Bytes,
85 pub mime_type: String,
87}
88
89#[derive(Debug, Clone)]
91pub struct CasterConfig {
92 pub runtime: String,
94 pub key: Option<String>,
96 pub caster_id: Option<String>,
98 pub max_concurrent: u32,
100 pub heartbeat_interval_secs: f64,
102 pub reconnect_base_delay_secs: f64,
104 pub reconnect_max_delay_secs: f64,
106 pub labels: HashMap<String, String>,
108 pub scale_policy: Option<ScalePolicy>,
110 pub load_report: Option<LoadReport>,
112}
113
114impl Default for CasterConfig {
115 fn default() -> Self {
116 Self {
117 runtime: "localhost:50070".into(),
118 key: None,
119 caster_id: None,
120 max_concurrent: 10,
121 heartbeat_interval_secs: 10.0,
122 reconnect_base_delay_secs: 1.0,
123 reconnect_max_delay_secs: 30.0,
124 labels: HashMap::new(),
125 scale_policy: None,
126 load_report: None,
127 }
128 }
129}
130
131#[derive(Debug, Clone)]
133pub struct ScalePolicy {
134 pub group: String,
135 pub scale_up_threshold: f64,
136 pub scale_down_threshold: f64,
137 pub sustained_secs: u64,
138 pub min_replicas: u32,
139 pub max_replicas: u32,
140 pub spawn_command: String,
141 pub shutdown_signal: String,
142}
143
144impl ScalePolicy {
145 pub fn new(group: impl Into<String>, spawn_command: impl Into<String>) -> Self {
146 Self {
147 group: group.into(),
148 spawn_command: spawn_command.into(),
149 ..Default::default()
150 }
151 }
152}
153
154impl Default for ScalePolicy {
155 fn default() -> Self {
156 Self {
157 group: String::new(),
158 scale_up_threshold: 0.8,
159 scale_down_threshold: 0.2,
160 sustained_secs: 30,
161 min_replicas: 1,
162 max_replicas: 1,
163 spawn_command: String::new(),
164 shutdown_signal: "SIGTERM".into(),
165 }
166 }
167}
168
169#[derive(Debug, Clone, Default)]
171pub struct LoadReport {
172 pub pressure: Option<f64>,
175 pub metrics: HashMap<String, f64>,
176}