Unverified Commit d95cc864 authored by Landon James's avatar Landon James Committed by GitHub
Browse files

Add `aws-smithy-wasm` crate with WASI http client (#3409)

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
This change adds a new crate, `aws-smithy-wasm`, that exports a SDK
compatible WASI http client. This is a continuation of the work in #2520
using the now stabilized WASI 0.2.0 interfaces from the [wasi
crate](https://crates.io/crates/wasi). This supports, but does not
finalize the work for #2087

## Description
<!--- Describe your changes in detail -->

Add a new crate, `aws-smithy-wasm` which exports a function
`wasi_http_client` that will provide the user with a WASI compatible
http client. This client is implemented by using the
`wasi::http::outgoing_handler`
[ref](https://docs.rs/wasi/0.12.0+wasi-0.2.0/wasi/http/outgoing_handler/index.html

)
along with some utility implementations of `TryFrom` to transform back
and worth between the types from the `http` crate and the `wasi::http`
types. It also exports a unit struct `WasmSleep` that impls the
`AsyncSleep` trait needed by the SDK.

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
This is tested via an integration test in
`aws/sdk/integration-tests/webassembly` that uses the wasi http-client
to vuild a config and an operation (that is not sent). It is further
tested in a new canary (`wasm_canary`) that calls the S3
`list_objects_v2` API.

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [X] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._

---------

Co-authored-by: default avatarEduardo Rodrigues <eduardomourar@users.noreply.github.com>
Co-authored-by: default avatarEduardo de Moura Rodrigues <16357187+eduardomourar@users.noreply.github.com>
Co-authored-by: default avatarysaito1001 <awsaito@amazon.com>
Co-authored-by: default avatarJohn DiSanti <jdisanti@amazon.com>
Co-authored-by: default avatarRussell Cohen <rcoh@amazon.com>
Co-authored-by: default avatarJohn DiSanti <john@vinylsquid.com>
parent 5b9d0c0f
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -16,3 +16,15 @@ message = "EKS Pod Identity is now supported as part of the default ECS credenti
references = ["smithy-rs#3416"]
meta = { "breaking" = false, "bug" = false, "tada" = true }
author = "jackkleeman"

[[aws-sdk-rust]]
message = "Added aws-smithy-wasm crate to enable SDK use in WASI compliant environments"
references = ["smithy-rs#2087", "smithy-rs#2520", "smithy-rs#3409", "aws-sdk-rust#59"]
meta = { "breaking" = false, "tada" = true, "bug" = false }
author = "landonxjames"

[[smithy-rs]]
message = "Added aws-smithy-wasm crate to enable SDK use in WASI compliant environments"
references = ["smithy-rs#2087", "smithy-rs#2520", "smithy-rs#3409"]
meta = { "breaking" = false, "tada" = true, "bug" = false, "target" = "client"}
author = "landonxjames"
+4 −1
Original line number Diff line number Diff line
[package]
name = "aws-config"
version = "0.0.0-smithy-rs-head"
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>", "Russell Cohen <rcoh@amazon.com>"]
authors = [
    "AWS Rust SDK Team <aws-sdk-rust@amazon.com>",
    "Russell Cohen <rcoh@amazon.com>",
]
description = "AWS SDK config and credential provider implementations."
edition = "2021"
exclude = ["test-data/*", "integration-tests/*"]
+1 −0
Original line number Diff line number Diff line
Cargo.lock
target/
webassembly/src/bindings.rs
+7 −1
Original line number Diff line number Diff line
@@ -11,6 +11,12 @@ for f in *; do
      echo
      echo "Testing ${f}..."
      echo "###############"
      if [ "$f" != "webassembly" ]; then
         cargo test --manifest-path "${f}/Cargo.toml" --all-features
      else
         # The webassembly tests use a custom runner set in config.toml that
         # is not picked up when running the tests outside of the package
         cd webassembly && cargo component test --all-features --all-targets && cd ..
      fi
   fi
done
+6 −0
Original line number Diff line number Diff line
@@ -3,3 +3,9 @@ target = "wasm32-wasi"

[target.wasm32-wasi]
rustflags = ["-C", "opt-level=1"]
runner = [
    "wasmtime",
    "-C", "cache=n",
    "-S", "preview2=y",
    "-S", "http=y"
]
Loading