Skip to main content

coreason_runtime_rust/
config.rs

1// Copyright (c) 2026 CoReason, Inc.
2// All rights reserved.
3
4use std::env;
5
6#[derive(Clone, Debug)]
7pub struct Config {
8    pub port: u16,
9    pub python_sidecar: String,
10    pub lancedb_uri: String,
11    pub plugins_dir: String,
12    pub telemetry_broker_url: String,
13    pub temporal_host: String,
14    pub master_gateway_url: String,
15}
16
17impl Config {
18    pub fn from_env() -> Self {
19        let port = env::var("PORT")
20            .ok()
21            .and_then(|p| p.parse().ok())
22            .unwrap_or(8080);
23
24        let python_sidecar =
25            env::var("PYTHON_SIDECAR_URL").unwrap_or_else(|_| "http://127.0.0.1:8000".to_string());
26
27        let lancedb_uri =
28            env::var("LANCEDB_URI").unwrap_or_else(|_| "/app/data/lancedb".to_string());
29
30        let plugins_dir =
31            env::var("PLUGINS_DIR").unwrap_or_else(|_| "/app/data/plugins".to_string());
32
33        let telemetry_broker_url = env::var("TELEMETRY_BROKER_URL")
34            .unwrap_or_else(|_| "http://localhost:8000".to_string());
35
36        let temporal_host =
37            env::var("TEMPORAL_HOST").unwrap_or_else(|_| "temporal:7233".to_string());
38
39        let master_gateway_url = env::var("COREASON_MASTER_GATEWAY_URL")
40            .unwrap_or_else(|_| "http://host.docker.internal:8080".to_string());
41
42        Self {
43            port,
44            python_sidecar,
45            lancedb_uri,
46            plugins_dir,
47            telemetry_broker_url,
48            temporal_host,
49            master_gateway_url,
50        }
51    }
52}