diff --git a/crates/adapter/src/fastly/core.rs b/crates/adapter/src/fastly/core.rs index e2430b45..5f6bc58e 100644 --- a/crates/adapter/src/fastly/core.rs +++ b/crates/adapter/src/fastly/core.rs @@ -122,6 +122,11 @@ pub struct DynamicBackendConfig { pub client_certificate: *const u8, pub client_certificate_len: u32, pub client_key: SecretHandle, + pub http_keepalive_time_ms: u32, + pub tcp_keepalive_enable: u32, + pub tcp_keepalive_interval_secs: u32, + pub tcp_keepalive_probes: u32, + pub tcp_keepalive_time_secs: u32, } impl Default for DynamicBackendConfig { @@ -145,6 +150,11 @@ impl Default for DynamicBackendConfig { client_certificate: std::ptr::null(), client_certificate_len: 0, client_key: 0, + http_keepalive_time_ms: 0, + tcp_keepalive_enable: 0, + tcp_keepalive_interval_secs: 0, + tcp_keepalive_probes: 0, + tcp_keepalive_time_secs: 0, } } } @@ -186,6 +196,7 @@ bitflags::bitflags! { const DONT_POOL = 1 << 12; const CLIENT_CERT = 1 << 13; const GRPC = 1 << 14; + const KEEPALIVE = 1 << 15; } } @@ -249,6 +260,10 @@ impl From for crate::bindings::fastly::api::http_types::Ba options.contains(BackendConfigOptions::CLIENT_CERT), ); flags.set(Self::GRPC, options.contains(BackendConfigOptions::GRPC)); + flags.set( + Self::KEEPALIVE, + options.contains(BackendConfigOptions::KEEPALIVE), + ); flags } } diff --git a/lib/compute-at-edge-abi/compute-at-edge.witx b/lib/compute-at-edge-abi/compute-at-edge.witx index 29d061a8..231a402b 100644 --- a/lib/compute-at-edge-abi/compute-at-edge.witx +++ b/lib/compute-at-edge-abi/compute-at-edge.witx @@ -920,6 +920,49 @@ (error $fastly_status))) ) + ;; Get the idle timeout for HTTP keepalive connections to the backend. + (@interface func (export "get_http_keepalive_time") + (param $backend string) + (result $err (expected + $timeout_ms + (error $fastly_status))) + ) + + ;; Get whether TCP keepalives have been enabled on the backend. + (@interface func (export "get_tcp_keepalive_enable") + (param $backend string) + (result $err (expected + $is_keepalive + (error $fastly_status))) + ) + + ;; Get how long to wait between sending each TCP keepalive probe to the + ;; backend. + (@interface func (export "get_tcp_keepalive_interval") + (param $backend string) + (result $err (expected + $timeout_secs + (error $fastly_status))) + ) + + ;; Get how long to wait after sending the last data before starting to send + ;; TCP keepalives to the backend. + (@interface func (export "get_tcp_keepalive_probes") + (param $backend string) + (result $err (expected + $probe_count + (error $fastly_status))) + ) + + ;; Get how long to wait after sending the last data before starting to send + ;; TCP keepalives to the backend. + (@interface func (export "get_tcp_keepalive_time") + (param $backend string) + (result $err (expected + $timeout_secs + (error $fastly_status))) + ) + ;; Returns 1 if the backend is configured to use SSL. (@interface func (export "is_ssl") (param $backend string) @@ -982,4 +1025,4 @@ (@interface func (export "get_vcpu_ms") (result $err (expected $vcpu_ms (error $fastly_status))) ) -) +) diff --git a/lib/compute-at-edge-abi/typenames.witx b/lib/compute-at-edge-abi/typenames.witx index 7dda6e3e..7d192415 100644 --- a/lib/compute-at-edge-abi/typenames.witx +++ b/lib/compute-at-edge-abi/typenames.witx @@ -140,8 +140,11 @@ (typename $port u16) (typename $timeout_ms u32) +(typename $timeout_secs u32) +(typename $probe_count u32) (typename $backend_exists u32) (typename $is_dynamic u32) +(typename $is_keepalive u32) (typename $is_ssl u32) (typename $backend_health (enum (@witx tag u32) @@ -187,6 +190,7 @@ $dont_pool $client_cert $grpc + $keepalive )) (typename $dynamic_backend_config @@ -209,6 +213,11 @@ (field $client_certificate (@witx pointer (@witx char8))) (field $client_certificate_len u32) (field $client_key $secret_handle) + (field $http_keepalive_time_ms $timeout_ms) + (field $tcp_keepalive_enable u32) + (field $tcp_keepalive_interval_secs $timeout_secs) + (field $tcp_keepalive_probes $probe_count) + (field $tcp_keepalive_time_secs $timeout_secs) )) ;;; TLS client certificate verified result from downstream. diff --git a/lib/data/viceroy-component-adapter.wasm b/lib/data/viceroy-component-adapter.wasm index edafc024..657aad70 100755 Binary files a/lib/data/viceroy-component-adapter.wasm and b/lib/data/viceroy-component-adapter.wasm differ diff --git a/lib/src/wiggle_abi/backend_impl.rs b/lib/src/wiggle_abi/backend_impl.rs index 44ea023d..441060c4 100644 --- a/lib/src/wiggle_abi/backend_impl.rs +++ b/lib/src/wiggle_abi/backend_impl.rs @@ -177,6 +177,51 @@ impl FastlyBackend for Session { Err(Error::NotAvailable("SSL version information")) } + fn get_http_keepalive_time( + &mut self, + memory: &mut wiggle::GuestMemory<'_>, + backend: wiggle::GuestPtr, + ) -> Result { + // Viceroy doesn't support pooling: + lookup_backend_definition(self, memory, backend).map(|_| 0) + } + + fn get_tcp_keepalive_enable( + &mut self, + memory: &mut wiggle::GuestMemory<'_>, + backend: wiggle::GuestPtr, + ) -> Result { + // Viceroy doesn't support TCP keepalives: + lookup_backend_definition(self, memory, backend).map(|_| 0) + } + + fn get_tcp_keepalive_interval( + &mut self, + memory: &mut wiggle::GuestMemory<'_>, + backend: wiggle::GuestPtr, + ) -> Result { + // Viceroy doesn't currently support TCP keepalives: + lookup_backend_definition(self, memory, backend).map(|_| 0) + } + + fn get_tcp_keepalive_probes( + &mut self, + memory: &mut wiggle::GuestMemory<'_>, + backend: wiggle::GuestPtr, + ) -> Result { + // Viceroy doesn't currently support TCP keepalives: + lookup_backend_definition(self, memory, backend).map(|_| 0) + } + + fn get_tcp_keepalive_time( + &mut self, + memory: &mut wiggle::GuestMemory<'_>, + backend: wiggle::GuestPtr, + ) -> Result { + // Viceroy doesn't currently support TCP keepalives: + lookup_backend_definition(self, memory, backend).map(|_| 0) + } + fn is_ssl( &mut self, memory: &mut wiggle::GuestMemory<'_>, diff --git a/lib/wit/deps/fastly/compute.wit b/lib/wit/deps/fastly/compute.wit index bde3e5ec..8d904b17 100644 --- a/lib/wit/deps/fastly/compute.wit +++ b/lib/wit/deps/fastly/compute.wit @@ -108,6 +108,7 @@ interface http-types { dont-pool, client-cert, grpc, + keepalive, } /// Create a backend for later use