Skip to main content

euv_core/dynamic/engine/
const.rs

1/// Default capacity of the bounded non-blocking `CandidateMailbox`.
2pub const DEFAULT_CANDIDATE_MAILBOX_CAPACITY: usize = 4;
3
4/// Default maximum size in bytes allowed for a single downloaded artifact (`16 MiB`).
5pub const DEFAULT_MAX_ARTIFACT_BYTES: u64 = 16 * 1024 * 1024;
6
7/// Default HTTP connect and read timeout in milliseconds for update requests.
8pub const DEFAULT_UPDATE_HTTP_TIMEOUT_MS: u64 = 5_000;
9
10/// Default SSE reconnect backoff interval in milliseconds.
11pub const DEFAULT_SSE_RECONNECT_MS: u64 = 100;
12
13/// Dedicated OS thread name assigned to the background `UpdateWorker`.
14pub const UPDATE_WORKER_THREAD_NAME: &str = "euv-update-worker";
15
16/// Environment variable overriding the dynamic hot-update server base URL.
17pub const ENV_EUV_UPDATE_URL: &str = "EUV_UPDATE_URL";
18
19/// Environment variable overriding the dynamic hot-update release channel name.
20pub const ENV_EUV_UPDATE_CHANNEL: &str = "EUV_UPDATE_CHANNEL";
21
22/// Environment variable configuring the persistent on-device hot-update cache directory.
23pub const ENV_EUV_UPDATE_CACHE_DIR: &str = "EUV_UPDATE_CACHE_DIR";
24
25/// Environment variable configuring an explicit HTTP forward proxy for hot updates.
26pub const ENV_EUV_PROXY_URL: &str = "EUV_PROXY_URL";
27
28/// Standard uppercase HTTPS proxy environment variable consulted by `resolve_proxy_env`.
29pub const ENV_HTTPS_PROXY: &str = "HTTPS_PROXY";
30
31/// Standard uppercase HTTP proxy environment variable consulted by `resolve_proxy_env`.
32pub const ENV_HTTP_PROXY: &str = "HTTP_PROXY";
33
34/// Standard lowercase HTTPS proxy environment variable fallback.
35pub const ENV_HTTPS_PROXY_LOWER: &str = "https_proxy";
36
37/// Standard lowercase HTTP proxy environment variable fallback.
38pub const ENV_HTTP_PROXY_LOWER: &str = "http_proxy";
39
40/// Default hot-update server URL used when `EUV_UPDATE_URL` is unset.
41pub const DEFAULT_HOT_UPDATE_SERVER_URL: &str = "http://127.0.0.1:8787";
42
43/// Default hot-update channel name used by `HotUpdateProxyConfig`.
44pub const DEFAULT_HOT_UPDATE_CHANNEL: &str = "prod";
45
46/// Default periodic manifest poll fallback cadence in seconds when SSE disconnects.
47pub const DEFAULT_POLL_FALLBACK_SECS: u64 = 30;
48
49/// Default HTTP port assumed when an update server URL omits an explicit `:port`.
50pub const DEFAULT_UPDATE_HTTP_PORT: u16 = 80;
51
52/// Relative subdirectory under `cache_dir` storing content-addressed verified OTA blobs.
53pub const HOT_UPDATE_CACHE_BLOBS_DIR: &str = "blobs";
54
55/// Filename under `cache_dir` persisting the latest verified active `ReleaseManifest`.
56pub const HOT_UPDATE_CACHE_ACTIVE_MANIFEST: &str = "active_manifest.json";
57
58/// Filename under `cache_dir` persisting the prior last-known-good `ReleaseManifest`.
59pub const HOT_UPDATE_CACHE_PREV_MANIFEST: &str = "previous_manifest.json";
60
61/// Synthetic `prepared_on_thread` source label identifying a candidate restored offline from disk cache.
62pub const UPDATE_CACHE_RESTORE_SOURCE: &str = "euv-update-cache";
63
64/// Temporary filename suffix used for atomic hot-update cache persistence writes.
65#[cfg(not(target_arch = "wasm32"))]
66pub(crate) const HOT_UPDATE_CACHE_TMP_SUFFIX: &str = ".tmp";
67
68/// Error message when a warmed WASM module emits neither `DynamicNodeSpec` nor `DynamicUpdateBundle`.
69pub(crate) const ERR_WASM_EMIT_EMPTY: &str =
70    "wasm artifact emitted neither DynamicNodeSpec nor DynamicUpdateBundle";
71
72/// HTTP header name carrying forward-proxy credentials.
73#[cfg(not(target_arch = "wasm32"))]
74pub(crate) const HDR_PROXY_AUTHORIZATION: &str = "Proxy-Authorization";
75
76/// HTTP header name keeping forward-proxied SSE streams alive.
77#[cfg(not(target_arch = "wasm32"))]
78pub(crate) const HDR_PROXY_CONNECTION: &str = "Proxy-Connection";
79
80/// Standard Base64 encoding alphabet used for HTTP Basic `Proxy-Authorization`.
81pub(crate) const BASE64_STD_TABLE: &[u8; 64] =
82    b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
83
84/// HTTP scheme prefix accepted by `HttpReleaseTransport`.
85#[cfg(not(target_arch = "wasm32"))]
86pub(crate) const UPDATE_HTTP_SCHEME: &str = "http://";
87
88/// HTTP header separator marking the end of response headers.
89#[cfg(not(target_arch = "wasm32"))]
90pub(crate) const HTTP_HEADER_END_MARKER: &[u8] = b"\r\n\r\n";
91
92/// HTTP header name for SSE stream resume cursor.
93#[cfg(not(target_arch = "wasm32"))]
94pub(crate) const HDR_LAST_EVENT_ID: &str = "Last-Event-ID";
95
96/// HTTP header name for byte-range resume requests.
97#[cfg(not(target_arch = "wasm32"))]
98pub(crate) const HDR_RANGE: &str = "Range";
99
100/// HTTP transfer-encoding chunked token.
101#[cfg(not(target_arch = "wasm32"))]
102pub(crate) const HDR_TRANSFER_ENCODING_CHUNKED: &str = "chunked";
103
104/// HTTP header key prefix for transfer encoding.
105#[cfg(not(target_arch = "wasm32"))]
106pub(crate) const HDR_TRANSFER_ENCODING_KEY: &str = "transfer-encoding";
107
108/// HTTP header key prefix for content length.
109#[cfg(not(target_arch = "wasm32"))]
110pub(crate) const HDR_CONTENT_LENGTH_KEY: &str = "content-length";
111
112/// SSE wire prefix for event identifier lines.
113#[cfg(not(target_arch = "wasm32"))]
114pub(crate) const SSE_WIRE_ID_PREFIX: &str = "id:";
115
116/// SSE wire prefix for event type lines.
117#[cfg(not(target_arch = "wasm32"))]
118pub(crate) const SSE_WIRE_EVENT_PREFIX: &str = "event:";
119
120/// SSE wire prefix for data payload lines.
121#[cfg(not(target_arch = "wasm32"))]
122pub(crate) const SSE_WIRE_DATA_PREFIX: &str = "data:";
123
124/// Delivery mode query token for Wasm Component channel.
125#[cfg(not(target_arch = "wasm32"))]
126pub(crate) const QUERY_MODE_WASM: &str = "wasm_component";
127
128/// Delivery mode query token for Declarative Data channel.
129#[cfg(not(target_arch = "wasm32"))]
130pub(crate) const QUERY_MODE_DATA: &str = "declarative_data";
131
132/// Error message when a worker URL does not start with `http://`.
133#[cfg(not(target_arch = "wasm32"))]
134pub(crate) const ERR_INVALID_HTTP_BASE_URL: &str =
135    "update server base_url must use http://host:port";
136
137/// Error message when a server returns a malformed HTTP response head.
138#[cfg(not(target_arch = "wasm32"))]
139pub(crate) const ERR_MALFORMED_HTTP_RESP: &str = "malformed HTTP response from update server";
140
141/// Error message when an HTTP status code is not 200 or 206.
142#[cfg(not(target_arch = "wasm32"))]
143pub(crate) const ERR_HTTP_NON_OK: &str = "unexpected HTTP status from update server";
144
145/// Error message when an artifact WASM binary fails ABI or export validation.
146pub(crate) const ERR_WASM_ARTIFACT_ABI: &str = "wasm artifact failed host ABI export check";
147
148/// Error message when a declarative artifact is not valid JSON `DynamicNodeSpec`.
149pub(crate) const ERR_DECLARATIVE_JSON: &str =
150    "declarative artifact payload is not a valid DynamicNodeSpec";
151
152/// Error message when a cross-route action is denied by host permissions.
153pub(crate) const ERR_ACTION_DENIED: &str = "cross-route action is not permitted by host policy";
154
155/// Error message when a cross-route action was cancelled before dispatch.
156pub(crate) const ERR_ACTION_CANCELLED: &str =
157    "cross-route action cancelled by stale generation token";
158
159/// Error message when no active release generation is installed on the runtime.
160pub(crate) const ERR_NO_ACTIVE_GENERATION: &str = "no active release generation installed";
161
162/// Error message when the background update worker thread cannot be spawned.
163#[cfg(not(target_arch = "wasm32"))]
164pub(crate) const ERR_WORKER_SPAWN: &str = "failed to spawn background update worker thread";
165
166/// Error message when a network transport is unavailable on `wasm32` in synchronous mode.
167#[cfg(target_arch = "wasm32")]
168pub(crate) const ERR_WASM32_SYNC_HTTP: &str =
169    "synchronous TCP HTTP transport unavailable on wasm32";