-
Notifications
You must be signed in to change notification settings - Fork 8
Conversation
But, as you probably have seen, the library has several cargo features: [features]
default = ["host"]
host = ["arbitrary", "bincode", "json", "protobuf", "serde", "text", "typeinfo", "wasmtime"]
arbitrary = ["dep:arbitrary"]
bincode = ["dep:bincode"]
json = ["dep:serde", "dep:serde_json", "dep:bigdecimal", "typeinfo"]
protobuf = ["dep:bincode", "dep:serde", "dep:prost"]
serde = ["dep:serde"]
stub = []
text = ["wasmtime", "dep:wasm-wave"]
typeinfo = ["dep:golem-wasm-ast"]
wasmtime = ["dep:wasmtime", "typeinfo"] These are important to reduce the huge amount of dependencies in various use cases, but most importantly to not have all these dependencies when it is used in the generated RPC stubs.
I think the existing So to sum it up:
The
I think we want the same functionality for the WAVE text format, and I assume that's already in the PR (will check after this comment). I would do the following:
I don't think we need a protobuf version of it. We already have protobuf values of |
wasm-rpc/src/lib.rs
Outdated
|
||
#[cfg(not(feature = "host"))] | ||
#[cfg(feature = "stub")] | ||
pub use bindings::golem::rpc::types::{NodeIndex, RpcError, Uri, WasmRpc, WitNode, WitValue}; | ||
|
||
#[cfg(feature = "host")] | ||
use ::wasmtime::component::bindgen; | ||
use golem_wasm_ast::analysis::{AnalysedResourceId, AnalysedResourceMode}; | ||
use wasm_wave::wasm::{WasmType, WasmValue, WasmValueError}; |
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.
Don't let your IDE do these imports, it breaks the feature flags. Either import under a feature condition, or use fully qualified names.
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.
Done (I think) - will not resolve conversation until you verify. Thanks
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.
Looks nice, I'm just asking one more restructuring and maybe a parameter type change then we can merge!
TypeAnnotatedValue
(a great inspiration fromwasm_wave::value::Value
) to provide a convenient way to inspect the result of worker invocation. Also, we can obtain wasm_wave::value::Value directly from TypeAnnotatedValue anytime. Just note that wasm_wave::value::Value doesn't handle resource handles for now. Therefore, we are not touching this part yet.Here is a practical use-case where this will be useful.
In golem-cloud, a
match
expr
such as the below one can be easily evaluated toTypeAnnotatedValue
. Meaning evaluation ofExpr
can go fromTypeAnnotatedValue
toTypeAnnotatedValue
And the evaluation goes as:
This otherwise is quite fragile and clunky if we were to inspect through textual/json format.
A
type-annotated-value
can be converted towasm_rpc::Value
usingFrom
instance.A type-annotated-value can also be turned into
serde_json::Value
keeping all our existing functionalities backward compatible. i.e, functions in current golem open source services will stay as it is. In the worker-bridge side, you can use simply invoke worker function that returns theProtoVal
version (instead of json) and use template service to get the template metadata that holds theVec<FunctionResult>
, and with these two you can formTypeAnnotatedValue
using the functionalities in wasm_rpc library. Note that worker-bridge is already part of worker-service-base, so it should be an easy thing to add a new function there and worker-bridge being able to use it.json::validate_function_result
function still returns aJsonValue
as before, however internally everything is computed in terms ofTypeAnnotatedValue
. That is, the actual validation is more cleaner now, but there is a cost involved here with intermediate representation when users needjson
.Given there are already good test coverage already for this validations to json, and given obtaining
JsonValue
is going through theTypeAnnotatedValue
logic, the existing tests are the proof the whole changes work.There is also an instance of
WasmValue
forTypeAnnotatedValue
in text module making to-and-from wave string for TypeAnnotatedValue.We can also get
WitValue
fromTypeAnnotatedValue
.