Skip to content
This repository was archived by the owner on Dec 16, 2020. It is now read-only.

Context support for Rust wasm filter SDK #399

Closed

Conversation

Shikugawa
Copy link
Member

Description: Context support for Rust wasm filter SDK. This is the only proposal implementation for SDK. So It may be required to discuss.
Risk Level: Low
Testing:
Docs Changes:
Release Notes:
[Optional Fixes #Issue]
[Optional Deprecated:]

@Shikugawa Shikugawa force-pushed the rust-sdk-context-support branch from 6ad8815 to 928f876 Compare February 6, 2020 16:19
Signed-off-by: shikugawa <Shikugawa@gmail.com>

Kick CI

Signed-off-by: shikugawa <Shikugawa@gmail.com>
@Shikugawa Shikugawa force-pushed the rust-sdk-context-support branch from 928f876 to 42d3da1 Compare February 6, 2020 16:29
pub trait ContextFactory {
fn create(
&self,
_root_context: Arc<Mutex<dyn RootContext + Sync + Send>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

i dont think you need Arc \ mutex here.
regular Rc without mutex should work, as IIRC VMs are instantiated per thread.
even if that wasn't the case i would still go for Arc but without mutex (similar to how envoy filters work today).

Copy link
Member Author

@Shikugawa Shikugawa Feb 7, 2020

Choose a reason for hiding this comment

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

@yuval-k It may be not required Mutex, but required Arc. Because we use only Rc, we can't guarantee the thread safety of static region variables and rustc can't pass them. It can pass with thread_local! macro. But we can't apply thread_local! and lazy_static! simultaneously.

So we should rewrite it to

_root_context: Arc<dyn RootContext + Sync + Send>

Signed-off-by: shikugawa <Shikugawa@gmail.com>
Signed-off-by: shikugawa <Shikugawa@gmail.com>
Signed-off-by: shikugawa <Shikugawa@gmail.com>
Signed-off-by: shikugawa <Shikugawa@gmail.com>
Signed-off-by: shikugawa <Shikugawa@gmail.com>
@PiotrSikora
Copy link
Contributor

Hi @Shikugawa, thanks writing this code and apologies for the delay!

However, please see: #351 (comment) and #384 (comment). I have a fairly more complete Rust SDK staged for publishing, but it's waiting for some approvals. Once it's out, I'm happy to incorporate changes from this PR. Sorry for the inconvenience!

@Shikugawa
Copy link
Member Author

@PiotrSikora Thanks. I'm developing Rust support not only context but also other functionalities. (e.g. pair marshaling/unmarshaling) I will add some functionality if there is missing that. I will help Rust SDK development!

Signed-off-by: shikugawa <Shikugawa@gmail.com>
@PiotrSikora
Copy link
Contributor

As you already noticed, the Rust SDK has been published at:
https://github.com/proxy-wasm/proxy-wasm-rust-sdk

Please feel free to reopen PRs there, thanks!

@PiotrSikora PiotrSikora closed this Mar 3, 2020
@Shikugawa Shikugawa deleted the rust-sdk-context-support branch March 7, 2020 08:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants