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 rpc_nats_url: Url,
24 pub rpc_timeout: Duration,
26 pub rpc_jwt: Option<String>,
28 pub rpc_key: Option<Arc<KeyPair>>,
30 pub rpc_tls: bool,
32 pub lattice: Arc<str>,
34 pub js_domain: Option<String>,
36 pub labels: HashMap<String, String>,
38 pub host_key: Arc<KeyPair>,
40 pub provider_shutdown_delay: Option<Duration>,
42 pub oci_opts: OciConfig,
44 pub allow_file_load: bool,
46 pub enable_structured_logging: bool,
48 pub log_level: LogLevel,
50 pub config_service_enabled: bool,
52 pub otel_config: OtelConfig,
54 pub version: String,
57 pub max_execution_time: Duration,
59 pub max_linear_memory: u32,
61 pub max_component_size: u64,
63 pub max_components: u32,
65 pub max_core_instances_per_component: u32,
67 pub heartbeat_interval: Option<Duration>,
69 pub experimental_features: Features,
71 pub http_admin: Option<SocketAddr>,
73 pub enable_component_auction: bool,
75 pub enable_provider_auction: bool,
77}
78
79#[derive(Clone, Debug, Default)]
81pub struct PolicyService {
82 pub policy_topic: Option<String>,
84 pub policy_changes_topic: Option<String>,
86 pub policy_timeout_ms: Option<Duration>,
88}
89
90impl Default for Host {
91 fn default() -> Self {
92 Self {
93 rpc_nats_url: Url::parse("nats://localhost:4222")
94 .expect("failed to parse RPC NATS URL"),
95 rpc_timeout: Duration::from_millis(2000),
96 rpc_jwt: None,
97 rpc_key: None,
98 rpc_tls: false,
99 lattice: "default".into(),
100 js_domain: None,
101 labels: HashMap::default(),
102 host_key: Arc::new(KeyPair::new_server()),
103 provider_shutdown_delay: None,
104 oci_opts: OciConfig::default(),
105 allow_file_load: false,
106 enable_structured_logging: false,
107 log_level: LogLevel::Info,
108 config_service_enabled: false,
109 otel_config: OtelConfig::default(),
110 version: env!("CARGO_PKG_VERSION").to_string(),
111 max_execution_time: Duration::from_millis(10 * 60 * 1000),
112 max_linear_memory: MAX_LINEAR_MEMORY,
114 max_component_size: MAX_COMPONENT_SIZE,
116 max_core_instances_per_component: DEFAULT_MAX_CORE_INSTANCES_PER_COMPONENT,
117 max_components: MAX_COMPONENTS,
118 heartbeat_interval: None,
119 experimental_features: Features::default(),
120 http_admin: None,
121 enable_component_auction: true,
122 enable_provider_auction: true,
123 }
124 }
125}