Skip to content
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

refactor: convert httpclient provider to bindgen #745

Conversation

vados-cosmonic
Copy link
Contributor

@vados-cosmonic vados-cosmonic commented Oct 12, 2023

Feature or Problem

This PR converts the httpclient provider to use provider-wit-bindgen, utilizing a couple features and bugfixes from other PRs:

#963
#983

Those PRs should land before this one, but it's not absolutely required.

Related Issues

#743
#680

Release Information

Consumer Impact

Testing

Built on platform(s)

  • x86_64-linux
  • aarch64-linux
  • x86_64-darwin
  • aarch64-darwin
  • x86_64-windows

Tested on platform(s)

  • x86_64-linux
  • aarch64-linux
  • x86_64-darwin
  • aarch64-darwin
  • x86_64-windows

Unit Test(s)

Acceptance or Integration

Pending implementation of wasi:outgoing-handler in host

Manual Verification

Tested locally

@vados-cosmonic vados-cosmonic requested review from a team as code owners October 12, 2023 15:32
Copy link
Member

@rvolosatovs rvolosatovs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requesting changes to prevent (accidental) merge until we have #680 done

Regarding the backwards-incompatibility, I expected we would serialize lists of tuples as maps (that could be a parameter to the macro invocation or we can just hardcode it for now)

crates/providers/http-client/Cargo.toml Outdated Show resolved Hide resolved
crates/providers/http-client/Cargo.toml Outdated Show resolved Hide resolved
@rvolosatovs
Copy link
Member

As of 2023/10/13, this code doesn't work due to conversions between map (which doesn't exist in WIT) as expressed by the Smithy contract and the list<tuple<string, list<u8>>> that WIT has to take. The error looks like this:

{"error":"actor: sending req: Host send error failed to call `wasmcloud:bus/host.call`: provider call failed: Error when handling invocation: Error when deserializing invocation: Syntax(\"invalid type: map, expected a sequence\")"}

This should be resolved by #680, as the host will likely have to munge invocations and responses to translate maps into/out of what WIT can actually understand.

#680 is not expected to be anyhow WIT-aware, message format should be fully backwards-compatible, meaning that wasi:http/outgoing-handler will be sending msgpack maps, just like before. Bindgen, however, should be able to handle that and decode a msgpack map into a list of tuples and other way round

@vados-cosmonic
Copy link
Contributor Author

vados-cosmonic commented Oct 12, 2023

meaning that wasi:http/outgoing-handler will be sending msgpack maps, just like before.

This seems to be a bit confusingly worded -- wasi:http/outgoing-handler cannot send out msgpack maps, because WIT doesn't have a map type. Is what you mean here is that #680 will make sure that the host intercepts wasi:http/outgoing-handler calls and converts them into objects that serialize as msgpack maps?

Bindgen, however, should be able to handle that and decode a msgpack map into a list of tuples and other way round

This is going to require some deeper changes to bindgen -- it's not clear that is safe to turn every list<tuple<string, list<u8>>> or any such type into something that serializes to a type that serializes to a msgpack map, and this would break normal WIT <-> WIT semantics.

This will likely have to be some kind of configurable option.

@rvolosatovs
Copy link
Member

meaning that wasi:http/outgoing-handler will be sending msgpack maps, just like before.

This seems to be a bit confusingly worded -- wasi:http/outgoing-handler cannot send out msgpack maps, because WIT doesn't have a map type. Is what you mean here is that #680 will make sure that the host intercepts wasi:http/outgoing-handler calls and converts them into objects that serialize as msgpack maps?

yes

Bindgen, however, should be able to handle that and decode a msgpack map into a list of tuples and other way round

This is going to require some deeper changes to bindgen -- it's not clear that is safe to turn every list<tuple<string, list<u8>>> or any such type into something that serializes to a type that serializes to a msgpack map, and this would break normal WIT <-> WIT semantics.

This will likely have to be some kind of configurable option.

Yes, ideally it's a parameter to the macro, as outlined in my original comment #745 (review), but for now we can just hard-code it, because we are the only users of this crate

@vados-cosmonic
Copy link
Contributor Author

Thanks for the clarifications -- I'm not too keen on hard-coding it, so I'll take a little time to think about a reasonable way to do it flexibly.

@vados-cosmonic vados-cosmonic requested a review from a team as a code owner October 13, 2023 16:14
connorsmith256 added a commit to connorsmith256/wasmCloud that referenced this pull request Oct 17, 2023
…rn/packages/washboard/eslint-plugin-react-refresh-0.4.3

build(deps-dev): Bump eslint-plugin-react-refresh from 0.3.5 to 0.4.3 in /packages/washboard
connorsmith256 added a commit to connorsmith256/wasmCloud that referenced this pull request Oct 17, 2023
…rn/packages/washboard/eslint-plugin-react-refresh-0.4.3

build(deps-dev): Bump eslint-plugin-react-refresh from 0.3.5 to 0.4.3 in /packages/washboard
@rvolosatovs
Copy link
Member

rvolosatovs commented Oct 27, 2023

@vados-cosmonic #804 is merged, so this is now unblocked, please rebase on latest main

@rvolosatovs rvolosatovs dismissed their stale review October 27, 2023 13:00

this is now unblocked

@vados-cosmonic vados-cosmonic force-pushed the refactor/convert-httpclient-to-provider-bindgen branch 2 times, most recently from e468156 to 8e70a6f Compare October 30, 2023 16:22
@rvolosatovs
Copy link
Member

@vados-cosmonic any idea why the provider build artifacts might have changed in this PR?
Does e.g.

cargo clippy --release -j 2 --all-targets --workspace -- --deny warnings

work locally for you with this change set?

@vados-cosmonic
Copy link
Contributor Author

Not sure, but it looks like the test-providers build in build.rs is failing to build after the rebase -- will look into it and see what changed.

@vados-cosmonic vados-cosmonic force-pushed the refactor/convert-httpclient-to-provider-bindgen branch from 8e70a6f to 13aff10 Compare October 31, 2023 12:11
@rvolosatovs
Copy link
Member

looks like this is blocked on #869 , but I have no permissions to approve/merge, so we'll have to wait until someone wakes up in US

@rvolosatovs
Copy link
Member

feel free to just commit the regenerated Cargo.lock

@brooksmtownsend
Copy link
Member

@rvolosatovs / @vados-cosmonic merged that PR!

@vados-cosmonic vados-cosmonic force-pushed the refactor/convert-httpclient-to-provider-bindgen branch from 13aff10 to a51ef03 Compare October 31, 2023 13:48
Copy link
Member

@brooksmtownsend brooksmtownsend left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rvolosatovs This looks good to me at a high level! Let me know if you need an additional approval here to merge but leaving it to you since you've been following

@vados-cosmonic
Copy link
Contributor Author

vados-cosmonic commented Oct 31, 2023

Hey @brooksmtownsend this isn't ready to merge yet -- I still haven't been able to get the tests working even after rebasing -- custom build isn't passing still even with the Cargo.lock changes.

Regardless of that, given that the host implementation changed there will likely be changes required here.

Going to put this back in Draft so people aren't reviewing it.

[EDIT] Builds are fine, Tests aren't, gotta squash the bugs, will update this and change it back to ready for review when done.

@vados-cosmonic vados-cosmonic marked this pull request as draft October 31, 2023 14:12
@vados-cosmonic vados-cosmonic force-pushed the refactor/convert-httpclient-to-provider-bindgen branch 2 times, most recently from 4282f74 to 0734b71 Compare November 3, 2023 17:14
@vados-cosmonic vados-cosmonic force-pushed the refactor/convert-httpclient-to-provider-bindgen branch 2 times, most recently from 299ca96 to 1566f42 Compare November 8, 2023 14:24
@vados-cosmonic vados-cosmonic force-pushed the refactor/convert-httpclient-to-provider-bindgen branch 2 times, most recently from 2036323 to dbfab52 Compare November 9, 2023 14:33
@vados-cosmonic vados-cosmonic marked this pull request as ready for review November 10, 2023 08:57
@vados-cosmonic vados-cosmonic force-pushed the refactor/convert-httpclient-to-provider-bindgen branch 4 times, most recently from f6cfe1c to 1284c06 Compare November 10, 2023 14:05
Copy link
Contributor

@connorsmith256 connorsmith256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One blocking request, and a few nits. I'm assuming you'll split out the bindgen code from this commit once #963 is merged?

crates/providers/http-client/src/bin/httpclient.rs Outdated Show resolved Hide resolved
crates/providers/http-client/src/lib.rs Outdated Show resolved Hide resolved
crates/providers/http-client/src/lib.rs Show resolved Hide resolved
crates/providers/http-client/src/lib.rs Outdated Show resolved Hide resolved
crates/providers/http-client/src/lib.rs Outdated Show resolved Hide resolved
@vados-cosmonic vados-cosmonic force-pushed the refactor/convert-httpclient-to-provider-bindgen branch from 50aabb0 to d4d2711 Compare November 11, 2023 02:08
@vados-cosmonic
Copy link
Contributor Author

Ah sorry @connorsmith256 refactoring bug made it's way in there... hopefully you don't have to re-approve (I just rebased to one commit again)

This commit converts the in-tree httpclient provider to use
provider-wit-bindgen for it's implementation.

Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
Co-authored-by: Connor Smith <connor.smith.256@gmail.com>
@vados-cosmonic vados-cosmonic force-pushed the refactor/convert-httpclient-to-provider-bindgen branch from e0d61dc to e99b335 Compare November 13, 2023 19:26
@thomastaylor312
Copy link
Contributor

@connorsmith256 asked me to merge this for him

@thomastaylor312 thomastaylor312 merged commit 123e536 into wasmCloud:main Nov 14, 2023
46 checks passed
@vados-cosmonic vados-cosmonic deleted the refactor/convert-httpclient-to-provider-bindgen branch November 14, 2023 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants