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
4 changes: 1 addition & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions crates/spin-sdk-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ pub fn http_service(_attr: TokenStream, item: TokenStream) -> TokenStream {
use ::spin_sdk::http::IntoResponse;

struct Spin;
::spin_sdk::http::wasip3::http::service::export!(Spin);
::spin_sdk::wasip3::http::service::export!(Spin);

impl ::spin_sdk::http::wasip3::exports::http::handler::Guest for self::Spin {
async fn handle(request: ::spin_sdk::http::wasip3::http::types::Request) -> Result<::spin_sdk::http::wasip3::http::types::Response, ::spin_sdk::http::wasip3::http::types::ErrorCode> {
impl ::spin_sdk::wasip3::exports::http::handler::Guest for self::Spin {
async fn handle(request: ::spin_sdk::wasip3::http::types::Request) -> Result<::spin_sdk::wasip3::http::types::Response, ::spin_sdk::wasip3::http::types::ErrorCode> {
let request = <::spin_sdk::http::Request as ::spin_sdk::http::FromRequest>::from_request(request)?;
::spin_sdk::http::IntoResponse::into_response(super::#func_name(request).await)
}
Expand Down
5 changes: 2 additions & 3 deletions crates/spin-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ name = "spin_sdk"
[features]
default = ["http", "key-value", "json", "llm", "mqtt", "mysql", "pg", "postgres4-types", "redis", "sqlite", "variables", "export-sdk-language"]
export-sdk-language = []
http = ["dep:wasip3", "dep:bytes", "dep:http-body", "dep:http-body-util", "dep:hyperium"]
http = ["dep:bytes", "dep:http-body", "dep:http-body-util", "dep:hyperium"]
key-value = []
json = ["dep:serde", "dep:serde_json"]
llm = []
Expand All @@ -37,16 +37,15 @@ variables = []

[dependencies]
spin-sdk-macro = { version = "5.1.1", path = "../spin-sdk-macro" }
wit-bindgen = "0.54"
anyhow = "1"
thiserror = "2.0.17"
wasip3 = { version = "0.5.0", git = "https://github.com/bytecodealliance/wasi-rs", features = ["http-compat", "wit-bindgen-macros"] }

# http
bytes = { version = "1.11.1", optional = true }
http-body = { version = "1.0.1", optional = true }
http-body-util = { version = "0.1.3", optional = true }
hyperium = { package = "http", version = "1.3.1", optional = true }
wasip3 = { version = "0.5.0", git = "https://github.com/bytecodealliance/wasi-rs", features = ["http-compat"], optional = true }

# pg
chrono = { version = "0.4.42", optional = true }
Expand Down
9 changes: 1 addition & 8 deletions crates/spin-sdk/src/http.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
#[doc(hidden)]
pub use wasip3;

pub use wasip3::{
http_compat::{IncomingMessage, Request, Response},
wit_bindgen::{self, spawn},
wit_future, wit_stream,
};
pub use wasip3::http_compat::{IncomingMessage, Request, Response};

use hyperium as http;
pub use hyperium::{HeaderMap, HeaderName, HeaderValue, Method, StatusCode, Uri};
Expand Down
5 changes: 5 additions & 0 deletions crates/spin-sdk/src/key_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@
//! # }
//! ```

use crate::wit_bindgen;

#[doc(hidden)]
/// Module containing wit bindgen generated code.
///
/// This is only meant for internal consumption.
pub mod wit {
#![allow(missing_docs)]

use crate::wit_bindgen;

wit_bindgen::generate!({
runtime_path: "crate::wit_bindgen::rt",
world: "spin-sdk-kv",
path: "wit",
generate_all,
Expand Down
5 changes: 3 additions & 2 deletions crates/spin-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,15 @@ extern "C" fn __spin_sdk_language() {}
#[export_name = concat!("spin-sdk-commit-", env!("SDK_COMMIT"))]
extern "C" fn __spin_sdk_hash() {}

#[doc(hidden)]
pub use wit_bindgen;
pub use wasip3::{self, wit_bindgen};

#[doc(hidden)]
pub mod experimental {
#![allow(missing_docs)]
use crate::wit_bindgen;

wit_bindgen::generate!({
runtime_path: "crate::wit_bindgen::rt",
world: "spin-sdk-experimental",
path: "wit",
generate_all,
Expand Down
2 changes: 2 additions & 0 deletions crates/spin-sdk/src/llm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
/// This is only meant for internal consumption.
pub mod wit {
#![allow(missing_docs)]
use crate::wit_bindgen;

wit_bindgen::generate!({
runtime_path: "crate::wit_bindgen::rt",
world: "spin-sdk-llm",
path: "wit",
generate_all,
Expand Down
2 changes: 2 additions & 0 deletions crates/spin-sdk/src/mqtt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
/// This is only meant for internal consumption.
pub mod wit {
#![allow(missing_docs)]
use crate::wit_bindgen;

wit_bindgen::generate!({
runtime_path: "crate::wit_bindgen::rt",
world: "spin-sdk-mqtt",
path: "wit",
generate_all,
Expand Down
2 changes: 2 additions & 0 deletions crates/spin-sdk/src/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
/// This is only meant for internal consumption.
pub mod wit {
#![allow(missing_docs)]
use crate::wit_bindgen;

wit_bindgen::generate!({
runtime_path: "crate::wit_bindgen::rt",
world: "spin-sdk-mysql",
path: "wit",
generate_all,
Expand Down
3 changes: 3 additions & 0 deletions crates/spin-sdk/src/pg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
// error fields instead of just a string
#![allow(clippy::result_large_err)]

use crate::wit_bindgen;
use std::sync::Arc;

#[doc(hidden)]
Expand All @@ -42,8 +43,10 @@ use std::sync::Arc;
/// This is only meant for internal consumption.
pub mod wit {
#![allow(missing_docs)]
use crate::wit_bindgen;

wit_bindgen::generate!({
runtime_path: "crate::wit_bindgen::rt",
world: "spin-sdk-pg",
path: "wit",
generate_all,
Expand Down
2 changes: 2 additions & 0 deletions crates/spin-sdk/src/redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
/// This is only meant for internal consumption.
pub mod wit {
#![allow(missing_docs)]
use crate::wit_bindgen;

wit_bindgen::generate!({
runtime_path: "crate::wit_bindgen::rt",
world: "spin-sdk-redis",
path: "wit",
generate_all,
Expand Down
4 changes: 4 additions & 0 deletions crates/spin-sdk/src/sqlite.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
use crate::wit_bindgen;

#[doc(hidden)]
/// Module containing wit bindgen generated code.
///
/// This is only meant for internal consumption.
pub mod wit {
#![allow(missing_docs)]
use crate::wit_bindgen;

wit_bindgen::generate!({
runtime_path: "crate::wit_bindgen::rt",
world: "spin-sdk-sqlite",
path: "wit",
generate_all,
Expand Down
2 changes: 2 additions & 0 deletions crates/spin-sdk/src/variables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
/// This is only meant for internal consumption.
pub mod wit {
#![allow(missing_docs)]
use crate::wit_bindgen;

wit_bindgen::generate!({
runtime_path: "crate::wit_bindgen::rt",
world: "spin-sdk-variables",
path: "wit",
generate_all,
Expand Down
2 changes: 1 addition & 1 deletion examples/http-concurrent-outbound-calls/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async fn handle_concurrent_outbound_http_calls(
// Spawn a task to run the application logic and stream the results
// to the client. `spawn` continues to run this future even after the
// function has exited with the return of the Response object.
spin_sdk::http::spawn(handle_concurrent_outbound_http_calls_impl(tx));
spin_sdk::wasip3::spawn(handle_concurrent_outbound_http_calls_impl(tx));

Ok(http::Response::new(body))
}
Expand Down
4 changes: 2 additions & 2 deletions examples/http-streaming/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ async fn handle_streaming(request: Request) -> impl IntoResponse {
// side will be sent out over the HTTP response.
let (mut tx, body) = bytes_stream_body();

// Use wit_bindgen::spawn to allow the async block to keep running
// Use wasip3::spawn to allow the async block to keep running
// after the handler returns.
spin_sdk::http::spawn(async move {
spin_sdk::wasip3::spawn(async move {
tx.send("-- INBOUND MESSAGE --\n".into()).await.unwrap();
// Keep processing data from the incoming body stream until it ends...
loop {
Expand Down
Loading