loongs-zhang commented on code in PR #21992: URL: https://github.com/apache/pulsar/pull/21992#discussion_r1494052381
########## pip/pip-331.md: ########## @@ -0,0 +1,129 @@ +# PIP-331: WASM Function API + +# Background knowledge + +WASM(WebAssembly) bytecode is designed to be encoded in a size- and load-time-efficient binary format. WASM aims to leverage the common hardware features available on various platforms to execute in browsers at machine code speed. + +WASI(WebAssembly System Interface) provide a portable interface for applications that run within a constrained sandbox environment, which allows WASM to run in non browser environments such as Linux. It's portable and secure. + +# Motivation + +The server and client sides of the Pulsar function use protobuf for decoupling. In principle, the language supported by protobuf can be supported by the pulsar function, now Pulsar provided the java, python and golang function client, but there are still many languages that are not supported. + +Before all language adaptations are completed (and it's almost entirely certain to be impossible), users cannot write pulsar function in their familiar languages. + +# Goals + +## In Scope + +Other languages, as long as their code can be compiled into WASM bytecode (such as Rust/golang/C++), users can use these languages to write pulsar function. + +## Out of Scope + +All existing abilities of the Java pulsar function client are not reimplemented, the WASM Pulsar functions is under the Java Pulsar functions. + +Due to the strict requirements of WASM on parameter types and for simplicity reasons, types other than `java.lang.Long` are not used as parameters or return value. + +# High Level Design Review Comment: > It would be very useful if you could explain how these diagram stages work and provide context. > 1. Do we provide a template Maven / Gradle project that contains the build plugin, which compiles to a WASM file? I think this should be done. Different languages require different tools to compile into WASM, which means multiple template projects need to be provided. > 2. Why must we move to a resource directory to run the unit test? Just for load WASM file correctly. > Does the build do it for us? Do we intend to provide a Unit test framework for the users to execute or author the tests? It is impossible to provide a unit testing framework, cause different languages require different tools to compile into WASM. But a github workflow can be done. > 3. Can you expand on how the "LoadFromResource" works? Just load the WASM file, see `WasmLoader#WasmLoader` in https://github.com/apache/pulsar/pull/21975. > Do you intend to use an open-source Java library that does that? Which library is it? [wasmtime-java](https://github.com/kawamuray/wasmtime-java) and [chicory](https://github.com/dylibso/chicory) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
