Skip to content

Commit

Permalink
Merge pull request #4813 from wasmerio/issue-4812-instaboot-headers-m…
Browse files Browse the repository at this point in the history
…ax-age

feat(configs): Add headers and max_age to InstaBoot capability
  • Loading branch information
syrusakbary authored Jun 6, 2024
2 parents dd8c3a3 + a7161fd commit e9c519c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/config/src/app/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ pub struct HttpRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub method: Option<String>,

/// HTTP headers added to the request.
#[serde(skip_serializing_if = "Option::is_none")]
pub headers: Option<Vec<HttpHeader>>,

/// Request body as a string.
#[serde(skip_serializing_if = "Option::is_none")]
pub body: Option<String>,
Expand All @@ -26,6 +30,15 @@ pub struct HttpRequest {
pub expect: Option<HttpRequestExpect>,
}

/// Definition for an HTTP header.
#[derive(
schemars::JsonSchema, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Debug,
)]
pub struct HttpHeader {
pub name: String,
pub value: String,
}

/// Validation checks for an [`HttpRequest`].
#[derive(
schemars::JsonSchema, serde::Serialize, serde::Deserialize, PartialEq, Eq, Clone, Debug,
Expand Down
17 changes: 17 additions & 0 deletions lib/config/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ pub struct AppConfigCapabilityMapV1 {
/// Enables app bootstrapping with startup snapshots.
#[serde(skip_serializing_if = "Option::is_none")]
pub instaboot: Option<AppConfigCapabilityInstaBootV1>,

/// Additional unknown capabilities.
///
/// This provides a small bit of forwards compatibility for newly added
/// capabilities.
#[serde(flatten)]
pub other: HashMap<String, serde_json::Value>,
}

/// Memory capability settings.
Expand Down Expand Up @@ -234,7 +241,17 @@ pub struct AppConfigCapabilityInstaBootV1 {
///
/// NOTE: if no requests are configured, then a single HTTP
/// request to '/' will be performed instead.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub requests: Vec<HttpRequest>,

/// Maximum age of snapshots.
///
/// Format: 5m, 1h, 2d, ...
///
/// After the specified time new snapshots will be created, and the old
/// ones discarded.
#[serde(skip_serializing_if = "Option::is_none")]
pub max_age: Option<String>,
}

#[cfg(test)]
Expand Down

0 comments on commit e9c519c

Please sign in to comment.