wasmcloud_host/wasmbus/
host_config.rs1use crate::OciConfig;
2
3use core::net::SocketAddr;
4
5use std::collections::HashMap;
6use std::sync::Arc;
7use std::time::Duration;
8
9use nkeys::KeyPair;
10use url::Url;
11use wasmcloud_core::{logging::Level as LogLevel, OtelConfig};
12use wasmcloud_runtime::{
13 DEFAULT_MAX_CORE_INSTANCES_PER_COMPONENT, MAX_COMPONENTS, MAX_COMPONENT_SIZE, MAX_LINEAR_MEMORY,
14};
15
16use crate::wasmbus::experimental::Features;
17
18#[allow(clippy::struct_excessive_bools)]
20#[derive(Clone, Debug)]
21pub struct Host {
22 pub ctl_nats_url: Url,
24 pub ctl_jwt: Option<String>,
26 pub ctl_key: Option<Arc<KeyPair>>,
28 pub ctl_tls: bool,
30 pub ctl_topic_prefix: String,
32 pub rpc_nats_url: Url,
34 pub rpc_timeout: Duration,
36 pub rpc_jwt: Option<String>,
38 pub rpc_key: Option<Arc<KeyPair>>,
40 pub rpc_tls: bool,
42 pub lattice: Arc<str>,
44 pub js_domain: Option<String>,
46 pub labels: HashMap<String, String>,
48 pub host_key: Option<Arc<KeyPair>>,
50 pub provider_shutdown_delay: Option<Duration>,
52 pub oci_opts: OciConfig,
54 pub allow_file_load: bool,
56 pub enable_structured_logging: bool,
58 pub log_level: LogLevel,
60 pub config_service_enabled: bool,
62 pub otel_config: OtelConfig,
64 pub policy_service_config: PolicyService,
66 pub secrets_topic_prefix: Option<String>,
68 pub version: String,
71 pub max_execution_time: Duration,
73 pub max_linear_memory: u32,
75 pub max_component_size: u64,
77 pub max_components: u32,
79 pub max_core_instances_per_component: u32,
81 pub heartbeat_interval: Option<Duration>,
83 pub experimental_features: Features,
85 pub http_admin: Option<SocketAddr>,
87 pub enable_component_auction: bool,
89 pub enable_provider_auction: bool,
91}
92
93#[derive(Clone, Debug, Default)]
95pub struct PolicyService {
96 pub policy_topic: Option<String>,
98 pub policy_changes_topic: Option<String>,
100 pub policy_timeout_ms: Option<Duration>,
102}
103
104impl Default for Host {
105 fn default() -> Self {
106 Self {
107 ctl_nats_url: Url::parse("nats://localhost:4222")
108 .expect("failed to parse control NATS URL"),
109 ctl_jwt: None,
110 ctl_key: None,
111 ctl_tls: false,
112 ctl_topic_prefix: "wasmbus.ctl".to_string(),
113 rpc_nats_url: Url::parse("nats://localhost:4222")
114 .expect("failed to parse RPC NATS URL"),
115 rpc_timeout: Duration::from_millis(2000),
116 rpc_jwt: None,
117 rpc_key: None,
118 rpc_tls: false,
119 lattice: "default".into(),
120 js_domain: None,
121 labels: HashMap::default(),
122 host_key: None,
123 provider_shutdown_delay: None,
124 oci_opts: OciConfig::default(),
125 allow_file_load: false,
126 enable_structured_logging: false,
127 log_level: LogLevel::Info,
128 config_service_enabled: false,
129 otel_config: OtelConfig::default(),
130 policy_service_config: PolicyService::default(),
131 secrets_topic_prefix: None,
132 version: env!("CARGO_PKG_VERSION").to_string(),
133 max_execution_time: Duration::from_millis(10 * 60 * 1000),
134 max_linear_memory: MAX_LINEAR_MEMORY,
136 max_component_size: MAX_COMPONENT_SIZE,
138 max_core_instances_per_component: DEFAULT_MAX_CORE_INSTANCES_PER_COMPONENT,
139 max_components: MAX_COMPONENTS,
140 heartbeat_interval: None,
141 experimental_features: Features::default(),
142 http_admin: None,
143 enable_component_auction: true,
144 enable_provider_auction: true,
145 }
146 }
147}