Skip to content

feat: make outgoing request based on wasi-http proposal #2520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
4e4fd4a
feat: make outgoing request based on wasi-http proposal
eduardomourar Mar 24, 2023
04c76bd
feat: support wasi in default configuration
eduardomourar Mar 31, 2023
e3547ca
chore: use bytes body with wasi-http
eduardomourar Apr 4, 2023
7c33972
chore: load credentials from environment variables
eduardomourar Apr 4, 2023
528d0f8
chore: run wasm integration tests
eduardomourar Apr 4, 2023
1ddbd45
chore: prepare git folder within cargo
eduardomourar Apr 4, 2023
c4c306f
chore(ci): update wasmtime to v8.0.0
eduardomourar Apr 23, 2023
3482726
chore: update to latest commit in wasi-http crate
eduardomourar Apr 23, 2023
17927d9
chore: separate variable for listed buckets
eduardomourar Apr 23, 2023
4691918
chore: set aws credentials env variables to empty string
eduardomourar Apr 23, 2023
24a56f0
chore: update wasi-http crate
eduardomourar Apr 27, 2023
d91a56b
chore: set component-model feature flag
eduardomourar Apr 27, 2023
dfe6aa0
chore: use wasi-preview2-prototype crate
eduardomourar Apr 29, 2023
904f002
chore: remove wasi dependency
eduardomourar Apr 29, 2023
cba7b09
chore: install wasmtime with component model feature
eduardomourar May 3, 2023
f6cb13a
chore: use default credentials provider chain
eduardomourar May 25, 2023
99418c1
feat: move logic to aws-smithy-wasm crate
eduardomourar May 25, 2023
77a4ac8
chore: use wasm crate in aws config
eduardomourar May 25, 2023
ee489fe
chore: re-enable timeout and retry config
eduardomourar May 25, 2023
ad01461
chore(smithy-async): compile to wasi with rt-tokio feature
eduardomourar May 25, 2023
0e93edb
chore: update wasi-preview2-prototype to v0.0.2
eduardomourar Aug 19, 2023
a5e858f
chore: run list objects instead
eduardomourar Aug 19, 2023
46e0c85
Merge remote-tracking branch 'upstream/main' into feat/default-wasi-http
eduardomourar Aug 19, 2023
53e84df
chore: fix misconfigured imports
eduardomourar Aug 29, 2023
ea29d56
chore: simplify wasm tests
eduardomourar Aug 29, 2023
bd15545
Merge remote-tracking branch 'upstream/main' into feat/default-wasi-http
eduardomourar Aug 29, 2023
a16bcc1
chore: remove cargo-wasi references
eduardomourar Aug 29, 2023
7d8638c
chore: remove unnecessary sparse registry config
eduardomourar Aug 29, 2023
b9028f3
chore: use temporarily wasmtime from git
eduardomourar Aug 29, 2023
69f50fe
chore: remove wasi sleep
eduardomourar Aug 29, 2023
f8d14af
feat(wasm): define top level setter for connector
eduardomourar Aug 29, 2023
0ac58ea
chore: remove default wasi connector from aws-config
eduardomourar Aug 29, 2023
f371193
chore: update wasm integration tests
eduardomourar Aug 29, 2023
1318f9a
chore: setup tracing in aws-smithy-wasm
eduardomourar Aug 29, 2023
5ca6108
chore: some extra clean up
eduardomourar Aug 29, 2023
d8bde29
Merge branch 'main' into feat/default-wasi-http
eduardomourar Aug 29, 2023
044d37a
chore: document wasi connector function
eduardomourar Aug 30, 2023
917e001
chore: ensure webassembly test can compile to non-wasm target
eduardomourar Aug 30, 2023
96c4e4e
Merge branch 'main' into feat/default-wasi-http
eduardomourar Aug 30, 2023
853e538
Merge branch 'main' into feat/default-wasi-http
eduardomourar Sep 6, 2023
6d6cfdb
chore: remove unnecessary tracing in adapter
eduardomourar Sep 8, 2023
46f6bf8
Merge remote-tracking branch 'upstream/main' into feat/default-wasi-http
eduardomourar Sep 8, 2023
93f7ffc
chore: update wasmtime to v13
eduardomourar Sep 20, 2023
db6e371
Merge remote-tracking branch 'upstream/main' into feat/default-wasi-http
eduardomourar Sep 20, 2023
3e5ad29
Revert "chore: prepare git folder within cargo"
eduardomourar Sep 21, 2023
00872d1
Merge branch 'main' into feat/default-wasi-http
eduardomourar Sep 21, 2023
ee71a78
Merge branch 'main' into feat/default-wasi-http
eduardomourar Sep 27, 2023
8f4d186
Merge remote-tracking branch 'upstream/main' into feat/default-wasi-http
eduardomourar Sep 28, 2023
1aacca3
Merge branch 'main' into feat/default-wasi-http
eduardomourar Sep 29, 2023
023ba22
Merge branch 'main' into feat/default-wasi-http
eduardomourar Oct 4, 2023
f98b4cb
Merge branch 'main' into feat/default-wasi-http
ysaito1001 Oct 9, 2023
843a4d7
Apply fixes for breaking changes introduced by the HttpClient refactor
jdisanti Oct 10, 2023
8bf2c15
Merge branch 'main' of github.com:smithy-lang/smithy-rs into feat/def…
rcoh Jan 11, 2024
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
5 changes: 4 additions & 1 deletion aws/rust-runtime/aws-config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[package]
name = "aws-config"
version = "0.0.0-smithy-rs-head"
authors = ["AWS Rust SDK Team <[email protected]>", "Russell Cohen <[email protected]>"]
authors = [
"AWS Rust SDK Team <[email protected]>",
"Russell Cohen <[email protected]>",
]
description = "AWS SDK config and credential provider implementations."
edition = "2021"
exclude = ["test-data/*", "integration-tests/*"]
Expand Down
6 changes: 6 additions & 0 deletions aws/sdk/integration-tests/webassembly/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ target = "wasm32-wasi"

[target.wasm32-wasi]
rustflags = ["-C", "opt-level=1"]
runner = [
"wasmtime",
"--disable-cache",
"--preview2",
"--wasi-modules=experimental-wasi-http",
]
24 changes: 14 additions & 10 deletions aws/sdk/integration-tests/webassembly/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
[package]
name = "webassembly"
version = "0.1.0"
authors = ["Eduardo Rodrigues <[email protected]>"]
authors = [
"Eduardo Rodrigues <[email protected]>",
]
description = """
These tests ensure that things will fail (or not fail) as expected
when target is set to wasm32-wasi for all SDK and runtime crates.
Expand All @@ -12,20 +14,22 @@ license = "Apache-2.0"
repository = "https://github.com/smithy-lang/smithy-rs"
publish = false

[lib]
crate-type = ["cdylib"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
aws-config = { path = "../../build/aws-sdk/sdk/aws-config", default-features = false, features = ["rt-tokio", "behavior-version-latest"]}
[target.'cfg(target_family = "wasm")'.dependencies]
aws-config = { path = "../../build/aws-sdk/sdk/aws-config", default-features = false, features = [
"rt-tokio",
"behavior-version-latest"
] }
aws-credential-types = { path = "../../build/aws-sdk/sdk/aws-credential-types", features = ["hardcoded-credentials"] }
aws-sdk-s3 = { path = "../../build/aws-sdk/sdk/s3", default-features = false }
aws-smithy-http = { path = "../../build/aws-sdk/sdk/aws-smithy-http" }
aws-smithy-runtime = { path = "../../build/aws-sdk/sdk/aws-smithy-runtime", features = ["client"] }
aws-smithy-runtime-api = { path = "../../build/aws-sdk/sdk/aws-smithy-runtime-api", features = ["client"] }
aws-smithy-types = { path = "../../build/aws-sdk/sdk/aws-smithy-types" }
aws-types = { path = "../../build/aws-sdk/sdk/aws-types" }
http = "0.2.8"
tokio = { version = "1.24.2", features = ["macros", "rt"] }
tower = "0.4.13"
aws-smithy-wasm = { path = "../../build/aws-sdk/sdk/aws-smithy-wasm" }
http = "0.2.9"
tokio = { version = "1.32.0", features = ["macros", "rt"] }

[target.'cfg(all(target_family = "wasm", target_os = "wasi"))'.dependencies]
wit-bindgen = { version = "0.11.0", features = ["macros", "realloc"] }
16 changes: 5 additions & 11 deletions aws/sdk/integration-tests/webassembly/src/default_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,22 @@

use crate::http::WasmHttpConnector;
use aws_config::retry::RetryConfig;
use aws_credential_types::Credentials;
use aws_smithy_types::timeout::TimeoutConfig;
use aws_types::region::Region;
use std::future::Future;

pub(crate) fn get_default_config() -> impl Future<Output = aws_config::SdkConfig> {
pub(crate) async fn get_default_config() -> aws_config::SdkConfig {
aws_config::from_env()
.region(Region::from_static("us-west-2"))
.credentials_provider(Credentials::from_keys(
"access_key",
"secret_key",
Some("session_token".to_string()),
))
.region("us-east-2")
.timeout_config(TimeoutConfig::disabled())
.retry_config(RetryConfig::disabled())
.no_credentials()
.http_client(WasmHttpConnector::new())
.load()
.await
}

#[tokio::test]
pub async fn test_default_config() {
let shared_config = get_default_config().await;
let client = aws_sdk_s3::Client::new(&shared_config);
assert_eq!(client.config().region().unwrap().to_string(), "us-west-2")
assert_eq!(client.config().region().unwrap().to_string(), "us-east-2")
}
14 changes: 8 additions & 6 deletions aws/sdk/integration-tests/webassembly/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
* SPDX-License-Identifier: Apache-2.0
*/

#![allow(dead_code)]

#[cfg(target_family = "wasm")]
mod default_config;
#[cfg(target_family = "wasm")]
mod http;
mod list_buckets;

#[tokio::main(flavor = "current_thread")]
pub async fn main() {
crate::list_buckets::s3_list_buckets().await
}
#[cfg(target_family = "wasm")]
mod list_objects;
#[cfg(all(target_family = "wasm", target_os = "wasi"))]
mod wasi;
20 changes: 0 additions & 20 deletions aws/sdk/integration-tests/webassembly/src/list_buckets.rs

This file was deleted.

31 changes: 31 additions & 0 deletions aws/sdk/integration-tests/webassembly/src/list_objects.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

use aws_sdk_s3::operation::list_objects_v2::ListObjectsV2Output;

async fn s3_list_objects() -> ListObjectsV2Output {
use crate::default_config::get_default_config;
use aws_sdk_s3::Client;

let shared_config = get_default_config().await;
let client = Client::new(&shared_config);
let operation = client
.list_objects_v2()
.bucket("nara-national-archives-catalog")
.delimiter("/")
.prefix("authority-records/organization/")
.max_keys(5)
.customize()
.await
.unwrap();
operation.send().await.unwrap()
}

#[tokio::test]
pub async fn test_s3_list_objects() {
let result = s3_list_objects().await;
let objects = result.contents();
assert!(objects.len() > 1);
}
32 changes: 32 additions & 0 deletions aws/sdk/integration-tests/webassembly/src/wasi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

// Needed for WASI-compliant environment as it expects specific functions
// to be exported such as `cabi_realloc`, `_start`, etc.

wit_bindgen::generate!({
inline: "
package aws:component

interface run {
run: func() -> result
}

world main {
export run
}
",
exports: {
"aws:component/run": Component
}
});

struct Component;

impl exports::aws::component::run::Guest for Component {
fn run() -> Result<(), ()> {
Ok(())
}
}
1 change: 1 addition & 0 deletions buildSrc/src/main/kotlin/CrateSet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ object CrateSet {
"aws-smithy-runtime-api",
"aws-smithy-types",
"aws-smithy-types-convert",
"aws-smithy-wasm",
"aws-smithy-xml",
).map { Crate(it, version(it)) }

Expand Down
1 change: 1 addition & 0 deletions rust-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ members = [
"aws-smithy-runtime-api",
"aws-smithy-types",
"aws-smithy-types-convert",
"aws-smithy-wasm",
"aws-smithy-xml",
]
27 changes: 27 additions & 0 deletions rust-runtime/aws-smithy-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "aws-smithy-wasm"
version = "0.0.0-smithy-rs-head"
authors = [
"AWS Rust SDK Team <[email protected]>",
"Eduardo Rodrigues <[email protected]>",
]
description = "Smithy WebAssembly configuration for smithy-rs."
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/awslabs/smithy-rs"

[target.'cfg(all(target_family = "wasm", target_os = "wasi"))'.dependencies]
aws-smithy-runtime-api = { path = "../aws-smithy-runtime-api" }
aws-smithy-http = { path = "../aws-smithy-http" }
bytes = "1"
http = "0.2.4"
tower = { version = "0.4.8" }
tracing = "0.1"
wasi-preview2-prototype = { version = "0.0.3", features = ["http-client"] }

[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
rustdoc-args = ["--cfg", "docsrs"]
# End of docs.rs metadata
Loading