Skip to content

Commit 3dcf279

Browse files
committed
Remove wasi-experimental-http support
- Update Rust SDK outbound_http implementation to use the newer WIT-based interface instead - Update docs - Add `make check-rust-examples` target to aid testing - Fix unrelated rust-outbound-redis example failure Signed-off-by: Lann Martin <lann.martin@fermyon.com>
1 parent 6bbf268 commit 3dcf279

File tree

18 files changed

+258
-606
lines changed

18 files changed

+258
-606
lines changed

Cargo.lock

Lines changed: 1 addition & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ lint:
1414
cargo clippy --all-targets --all-features -- -D warnings
1515
cargo fmt --all -- --check
1616

17+
.PHONY: check-rust-examples
18+
check-rust-examples:
19+
for manifest_path in examples/*/Cargo.toml; do \
20+
cargo clippy --manifest-path "$${manifest_path}" -- -D warnings || exit 1 ; \
21+
done
22+
1723
.PHONY: test-unit
1824
test-unit:
1925
RUST_LOG=$(LOG_LEVEL) cargo test --all --no-fail-fast -- --skip integration_tests --nocapture --include-ignored

crates/outbound-http/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ tokio = { version = "1.4.0", features = [ "full" ] }
1919
tracing = { version = "0.1", features = [ "log" ] }
2020
tracing-futures = "0.2"
2121
url = "2.2.1"
22-
wasi-experimental-http-wasmtime = "0.10.0"
2322
wit-bindgen-wasmtime = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "dde4694aaa6acf9370206527a798ac4ba6a8c5b8" }
Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
11
use anyhow::Result;
2+
use wit_bindgen_wasmtime::wasmtime::Linker;
3+
24
use spin_engine::{
35
host_component::{HostComponent, HostComponentsStateHandle},
46
RuntimeContext,
57
};
68
use spin_manifest::CoreComponent;
7-
use wasi_experimental_http_wasmtime::{HttpCtx as ExperimentalHttpCtx, HttpState};
8-
use wit_bindgen_wasmtime::wasmtime::Linker;
99

1010
use crate::OutboundHttp;
1111

1212
pub struct OutboundHttpComponent;
1313

1414
impl HostComponent for OutboundHttpComponent {
15-
type State = (OutboundHttp, ExperimentalHttpCtx);
15+
type State = OutboundHttp;
1616

1717
fn add_to_linker<T>(
1818
linker: &mut Linker<RuntimeContext<T>>,
1919
data_handle: HostComponentsStateHandle<Self::State>,
2020
) -> Result<()> {
21-
crate::add_to_linker(linker, move |ctx| &mut data_handle.get_mut(ctx).0)?;
22-
HttpState::new()
23-
.expect("HttpState::new failed")
24-
.add_to_linker(linker, move |ctx| data_handle.get(ctx).1.clone())?;
21+
crate::add_to_linker(linker, move |ctx| data_handle.get_mut(ctx))?;
2522
Ok(())
2623
}
2724

2825
fn build_state(&self, component: &CoreComponent) -> Result<Self::State> {
29-
let outbound_http = OutboundHttp {
30-
allowed_hosts: Some(component.wasm.allowed_http_hosts.clone()),
31-
};
32-
let experimental_http = ExperimentalHttpCtx {
26+
Ok(OutboundHttp {
3327
allowed_hosts: Some(component.wasm.allowed_http_hosts.clone()),
34-
max_concurrent_requests: None,
35-
};
36-
Ok((outbound_http, experimental_http))
28+
})
3729
}
3830
}

docs/content/configuration.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ Each `component` object has the following fields:
8282
WebAssembly module. For example
8383
`{ source = "content/", destination = "/"}`.
8484
- `allowed_http_hosts` (OPTIONAL): List of HTTP hosts the component is allowed
85-
to make HTTP requests to (using the
86-
[WASI experimental HTTP library](https://github.com/deislabs/wasi-experimental-http))
85+
to make HTTP requests to
8786
- `trigger` (REQUIRED): Trigger configuration for the component. Triggers are
8887
the components that generate events that cause the execution of components.
8988
The trigger configuration for a component must be compatible with the top-level

docs/content/http-trigger.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ record response {
146146
```
147147

148148
> The same HTTP types are also used to model the API for sending outbound
149-
> HTTP requests, and you can see its implementation in
150-
> [the WASI toolkit repository](https://github.com/fermyon/wasi-experimental-toolkit).
149+
> HTTP requests.
151150
152151
Then, we define the entry point for a Spin HTTP component:
153152

examples/config-rust/Cargo.lock

Lines changed: 17 additions & 87 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)