Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions docs/rust-server-port.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,11 @@ contract fixture before its correction.
Capabilities are true only where native serves the feature.
`workflow_activity_result_inspection` is now advertised: the
`cluster-capabilities` fixture qualifies the activity result read against
published 2.11.7. Native advertises no manifest it does not publish and no
response compression. `native_unqualified` names each member it still
published 2.11.7. Native advertises no manifest it does not publish.
Like PHP's `CompressResponse`, native gzip- or deflate-encodes JSON answers
of 1024 bytes or more when `Accept-Encoding` allows it, and advertises
`response_compression: ["gzip", "deflate"]`, unless
`DW_COMPRESSION_ENABLED` is false. `native_unqualified` names each member it still
leaves out: `topology`, the diagnostics view, the external payload
transaction limit and the conformance manifests. Since server#1005 (3.1.0)
native serves `supported_sdk_versions` and `client_compatibility` from one
Expand Down
4 changes: 2 additions & 2 deletions rust/src/config_audit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ pub const SETTINGS: &[Setting] = &[
Setting { name: "DW_BOOTSTRAP_RETRIES", legacy: Some("WORKFLOW_SERVER_BOOTSTRAP_RETRIES"), disposition: Ignored },
Setting { name: "DW_CALLER_LABEL_HEADER", legacy: Some("WORKFLOW_SERVER_CALLER_LABEL_HEADER"), disposition: Ignored },
Setting { name: "DW_CALLER_TYPE_HEADER", legacy: Some("WORKFLOW_SERVER_CALLER_TYPE_HEADER"), disposition: Ignored },
Setting { name: "DW_COMPRESSION_ENABLED", legacy: Some("WORKFLOW_SERVER_COMPRESSION_ENABLED"), disposition: Ignored },
Setting { name: "DW_COMPRESSION_ENABLED", legacy: Some("WORKFLOW_SERVER_COMPRESSION_ENABLED"), disposition: Honored },
Setting { name: "DW_DEFAULT_NAMESPACE", legacy: Some("WORKFLOW_SERVER_DEFAULT_NAMESPACE"), disposition: Refused(AnyCase("default"), DEFAULT_NAMESPACE) },
Setting { name: "DW_DUE_TIMER_RECOVERY_SCAN_LIMIT", legacy: Some("WORKFLOW_SERVER_DUE_TIMER_RECOVERY_SCAN_LIMIT"), disposition: Ignored },
Setting { name: "DW_ENV_AUDIT_STRICT", legacy: None, disposition: Honored },
Expand Down Expand Up @@ -995,7 +995,7 @@ mod tests {
&[("DW_V2_PIN_TO_RECORDED_FINGERPRINT", "no")],
&[("DW_SERIALIZER", "")],
&[("DW_STORAGE_CONNECTION", "pgsql"), ("DB_CONNECTION", "pgsql")],
// Ignored and reported settings take any value.
// Ignored and reported settings, and honored booleans, take any value.
&[("DW_MAX_PENDING_ACTIVITIES", "10"), ("DW_COMPRESSION_ENABLED", "false")],
];
for values in accepted {
Expand Down
6 changes: 3 additions & 3 deletions rust/src/runtime/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ pub(super) fn capabilities() -> Value {
json!({"schema": "durable_workflow.protocol.Value", "fingerprint": super::history_export::VALUE_FINGERPRINT,
"framing": "single_object", "magic_hex": "c301"}),
);
// Native sends uncompressed responses.
map.insert("response_compression".into(), json!([]));
// PHP's CompressResponse encodings, unless DW_COMPRESSION_ENABLED is false.
map.insert("response_compression".into(), json!(super::response_compression::advertised()));
Value::Object(map)
}

Expand Down Expand Up @@ -244,7 +244,7 @@ mod tests {
assert_eq!(caps["child_workflow_start_turn"], json!(true));
assert_eq!(caps["condition_wait_idempotent_reopen"], json!(true));
assert_eq!(caps["condition_wait_occurrence_deadline"], json!(true));
assert_eq!(caps["response_compression"], json!([]));
assert_eq!(caps["response_compression"], json!(["gzip", "deflate"]));
assert_eq!(caps["timer_runtime_contract"], json!(false));
assert_eq!(caps["principal_attribution_contract"], json!(true));
}
Expand Down
12 changes: 1 addition & 11 deletions rust/src/runtime/history_pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub(super) fn compress(payload: &mut Value, encoding: Option<&'static str>) -> R
}
let json = serde_json::to_vec(events)?;
let compressed = match encoding {
"gzip" => gzip(&json),
"gzip" => super::response_compression::gzip(&json),
_ => miniz_oxide::deflate::compress_to_vec(&json, LEVEL),
};
payload["history_events"] = json!([]);
Expand All @@ -122,16 +122,6 @@ pub(super) fn compress(payload: &mut Value, encoding: Option<&'static str>) -> R
Ok(())
}

/// `gzencode`: an RFC 1952 member around one raw DEFLATE stream.
fn gzip(data: &[u8]) -> Vec<u8> {
const CRC32: crc::Crc<u32> = crc::Crc::<u32>::new(&crc::CRC_32_ISO_HDLC);
// Magic, deflate method, no flags or time, default level, Unix.
let mut member = vec![0x1f, 0x8b, 8, 0, 0, 0, 0, 0, 0, 3];
member.extend(miniz_oxide::deflate::compress_to_vec(data, LEVEL));
member.extend(CRC32.checksum(data).to_le_bytes());
member.extend((data.len() as u32).to_le_bytes());
member
}

#[cfg(test)]
mod tests {
Expand Down
2 changes: 2 additions & 0 deletions rust/src/runtime/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ pub fn router(runtime: Runtime) -> Router {
.layer(middleware::from_fn_with_state(runtime.clone(), storage_admission_guard))
.layer(middleware::from_fn_with_state(runtime.clone(), guard))
.layer(middleware::from_fn(super::payload_limits::enforce))
// PHP's CompressResponse wraps every answer, refusals included.
.layer(middleware::from_fn(super::response_compression::compress))
.with_state(runtime)
}

Expand Down
1 change: 1 addition & 0 deletions rust/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ mod command_payloads;
mod completion_rules;
mod deployments;
mod priority_fairness;
mod response_compression;
mod route_fallback;
mod redrive;
mod redrive_plan;
Expand Down
Loading