-
Notifications
You must be signed in to change notification settings - Fork 196
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
Add aws-smithy-wasm
crate with WASI http client
#3409
Merged
jdisanti
merged 90 commits into
smithy-lang:main
from
landonxjames:landonxjames/wasi-2-http
Feb 28, 2024
+2,371
−152
Merged
Changes from 86 commits
Commits
Show all changes
90 commits
Select commit
Hold shift + click to select a range
4e4fd4a
feat: make outgoing request based on wasi-http proposal
eduardomourar 04c76bd
feat: support wasi in default configuration
eduardomourar e3547ca
chore: use bytes body with wasi-http
eduardomourar 7c33972
chore: load credentials from environment variables
eduardomourar 528d0f8
chore: run wasm integration tests
eduardomourar 1ddbd45
chore: prepare git folder within cargo
eduardomourar c4c306f
chore(ci): update wasmtime to v8.0.0
eduardomourar 3482726
chore: update to latest commit in wasi-http crate
eduardomourar 17927d9
chore: separate variable for listed buckets
eduardomourar 4691918
chore: set aws credentials env variables to empty string
eduardomourar 24a56f0
chore: update wasi-http crate
eduardomourar d91a56b
chore: set component-model feature flag
eduardomourar dfe6aa0
chore: use wasi-preview2-prototype crate
eduardomourar 904f002
chore: remove wasi dependency
eduardomourar cba7b09
chore: install wasmtime with component model feature
eduardomourar f6cb13a
chore: use default credentials provider chain
eduardomourar 99418c1
feat: move logic to aws-smithy-wasm crate
eduardomourar 77a4ac8
chore: use wasm crate in aws config
eduardomourar ee489fe
chore: re-enable timeout and retry config
eduardomourar ad01461
chore(smithy-async): compile to wasi with rt-tokio feature
eduardomourar 0e93edb
chore: update wasi-preview2-prototype to v0.0.2
eduardomourar a5e858f
chore: run list objects instead
eduardomourar 46e0c85
Merge remote-tracking branch 'upstream/main' into feat/default-wasi-http
eduardomourar 53e84df
chore: fix misconfigured imports
eduardomourar ea29d56
chore: simplify wasm tests
eduardomourar bd15545
Merge remote-tracking branch 'upstream/main' into feat/default-wasi-http
eduardomourar a16bcc1
chore: remove cargo-wasi references
eduardomourar 7d8638c
chore: remove unnecessary sparse registry config
eduardomourar b9028f3
chore: use temporarily wasmtime from git
eduardomourar 69f50fe
chore: remove wasi sleep
eduardomourar f8d14af
feat(wasm): define top level setter for connector
eduardomourar 0ac58ea
chore: remove default wasi connector from aws-config
eduardomourar f371193
chore: update wasm integration tests
eduardomourar 1318f9a
chore: setup tracing in aws-smithy-wasm
eduardomourar 5ca6108
chore: some extra clean up
eduardomourar d8bde29
Merge branch 'main' into feat/default-wasi-http
eduardomourar 044d37a
chore: document wasi connector function
eduardomourar 917e001
chore: ensure webassembly test can compile to non-wasm target
eduardomourar 96c4e4e
Merge branch 'main' into feat/default-wasi-http
eduardomourar 853e538
Merge branch 'main' into feat/default-wasi-http
eduardomourar 6d6cfdb
chore: remove unnecessary tracing in adapter
eduardomourar 46f6bf8
Merge remote-tracking branch 'upstream/main' into feat/default-wasi-http
eduardomourar 93f7ffc
chore: update wasmtime to v13
eduardomourar db6e371
Merge remote-tracking branch 'upstream/main' into feat/default-wasi-http
eduardomourar 3e5ad29
Revert "chore: prepare git folder within cargo"
eduardomourar 00872d1
Merge branch 'main' into feat/default-wasi-http
eduardomourar ee71a78
Merge branch 'main' into feat/default-wasi-http
eduardomourar 8f4d186
Merge remote-tracking branch 'upstream/main' into feat/default-wasi-http
eduardomourar 1aacca3
Merge branch 'main' into feat/default-wasi-http
eduardomourar 023ba22
Merge branch 'main' into feat/default-wasi-http
eduardomourar f98b4cb
Merge branch 'main' into feat/default-wasi-http
ysaito1001 843a4d7
Apply fixes for breaking changes introduced by the HttpClient refactor
jdisanti 8bf2c15
Merge branch 'main' of github.com:smithy-lang/smithy-rs into feat/def…
rcoh 086f557
Merge branch 'main' into landonxjames/wasi-2-http
landonxjames 8a32aff
Reimplemented SDK's HttpConnector with WASI types
landonxjames 83f079a
Wasm connector is building now
landonxjames a6cdb9f
Adding http-1x feature to runtime-api dependency
landonxjames e5feef2
Updating tests for wasi http connector
landonxjames f621e61
Updating wasi http to drop child resources
landonxjames b102e2b
Basic test setup for wasi should work in CI
landonxjames bb8bb4d
Update CHANGELOG.next.toml
landonxjames 6d39c43
Merge branch 'main' into landonxjames/wasi-2-http
landonxjames d0feecb
Update cargo-component to install nightly for MSRV
landonxjames 9a653b3
Lint updates
landonxjames 2701297
CI updates
landonxjames 02632f2
Update CHANGELOG.next.toml
landonxjames 1df0bf6
Update rust-runtime/aws-smithy-wasm/Cargo.toml
landonxjames 23db87e
Update rust-runtime/aws-smithy-wasm/Cargo.toml
landonxjames b2134c7
Update rust-runtime/aws-smithy-wasm/src/wasi.rs
landonxjames 1005865
Update rust-runtime/aws-smithy-wasm/src/wasi.rs
landonxjames 68ae686
Apply suggestions from code review
landonxjames a38ef6b
Updating build scripts with PR feedback
landonxjames b2ff222
Updating error handling
landonxjames bf14237
Update WASI HTTP client
landonxjames cd091fb
First pass at a wasm canary
landonxjames 43f9525
Merge branch 'smithy-lang:main' into landonxjames/wasi-2-http
landonxjames 42c3b4f
Slightly farther in getting wasmtime to run
landonxjames 3fc1aa8
Wasm canary test works locally
landonxjames 352cdfd
Add WasmSleep struct to wasm crate
landonxjames ade60da
Cleaning up some of the canary committed
landonxjames 7eeb60d
Added wasm_canary to the canary runner
landonxjames 3d1b9b4
Fixing canary builder tests
landonxjames 147a26a
Increase canary timeouts wasm canary is slow
landonxjames 0c41440
Apply suggestions from code review
landonxjames bd2006f
Merge branch 'main' into landonxjames/wasi-2-http
landonxjames c883aad
Updates from PR feedback
landonxjames a778a18
Bump version of wasmtime-cli in Dockerfile
landonxjames 6a174b3
Adding allowed external types to aws-smity-wasm
landonxjames f6720a3
Update rust-runtime/aws-smithy-wasm/src/wasi.rs
landonxjames 778bfb0
Update CHANGELOG.next.toml
jdisanti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/*"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
Cargo.lock | ||
target/ | ||
webassembly/src/bindings.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|
@@ -12,20 +14,34 @@ license = "Apache-2.0" | |
repository = "https://github.com/smithy-lang/smithy-rs" | ||
publish = false | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[features] | ||
default = ["test-util"] | ||
test-util = [] | ||
# 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.16.0", features = ["macros", "realloc"] } | ||
|
||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
# metadata used by cargo-component to identify which wit world to embed in the binary | ||
[package.metadata.component] | ||
package = "aws:component" |
32 changes: 0 additions & 32 deletions
32
aws/sdk/integration-tests/webassembly/src/default_config.rs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
use aws_config::retry::RetryConfig; | ||
use aws_sdk_s3::operation::list_objects_v2::builders::ListObjectsV2FluentBuilder; | ||
use aws_sdk_s3::Client; | ||
use aws_smithy_types::timeout::TimeoutConfig; | ||
use aws_smithy_wasm::wasi::WasiHttpClientBuilder; | ||
|
||
pub(crate) async fn get_default_wasi_config() -> aws_config::SdkConfig { | ||
let http_client = WasiHttpClientBuilder::new().build(); | ||
aws_config::from_env() | ||
.region("us-east-2") | ||
.timeout_config(TimeoutConfig::disabled()) | ||
.retry_config(RetryConfig::disabled()) | ||
.no_credentials() | ||
.http_client(http_client) | ||
.load() | ||
.await | ||
} | ||
|
||
#[tokio::test] | ||
pub async fn test_default_config() { | ||
let shared_config = get_default_wasi_config().await; | ||
let client = aws_sdk_s3::Client::new(&shared_config); | ||
assert_eq!(client.config().region().unwrap().to_string(), "us-east-2") | ||
} | ||
|
||
async fn s3_list_objects_operation() -> ListObjectsV2FluentBuilder { | ||
let shared_config = get_default_wasi_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); | ||
|
||
operation | ||
} | ||
|
||
// Test constructing an operation using an SdkConfig with a WASI http client | ||
// We do not send the request to keep these tests sandboxable, a full test of | ||
// the client is in the SDK canary. | ||
#[tokio::test] | ||
pub async fn test_operation_construction() { | ||
let operation = s3_list_objects_operation().await; | ||
assert_eq!( | ||
operation.get_bucket(), | ||
&Some("nara-national-archives-catalog".to_string()) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[package] | ||
name = "aws-smithy-wasm" | ||
version = "0.1.0" | ||
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" | ||
|
||
[dependencies] | ||
aws-smithy-async = { path = "../aws-smithy-async" } | ||
aws-smithy-runtime-api = { path = "../aws-smithy-runtime-api", features = ["http-1x"]} | ||
aws-smithy-http = { path = "../aws-smithy-http" } | ||
aws-smithy-types = { path = "../aws-smithy-types" } | ||
bytes = "1" | ||
http = "1.0.0" | ||
tokio = { version = "1.36.0", features = ["rt", "macros", "time"] } | ||
tower = "0.4.13" | ||
tracing = "0.1.40" | ||
|
||
[target.'cfg(all(target_family = "wasm", target_os = "wasi"))'.dependencies] | ||
wasi = "0.12.0+wasi-0.2.0" | ||
|
||
[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 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we call the crate aws-smithy-wasi, or do you envision this being used for all WASM runtime environments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the moment everything in here is wasi related, but I can see a future where more wasm tooling is published and keeping both wasm/wasi functionality in the same crate makes sense to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up adding an
AsyncSleep
impl in this crate too and that should work for any Wasm environment, WASI compliant or not. Its under awasm
module in the crate, so now I think keep the name definitely makes senseThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up adding an
AsyncSleep
impl in this crate too and that should work for any Wasm environment, WASI compliant or not. Its under a wasm module in the crate, so now I think keep the name definitely makes sense