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

[do not review] feat: add small wasmtime prototype #3038

Closed
wants to merge 1 commit into from

Conversation

kostasrim
Copy link
Contributor

@kostasrim kostasrim commented May 10, 2024

  • embed wasmtime in dragonfly
  • add hello example as an API export function
  • add UDF example
  • add cpp sdk example

How to use:

Before you call cmake or blaze make sure you compile wasmtime:

cd dragonfly/wasmtime && cargo build --release -p wasmtime-c-api

Then call blaze or cmake && ninja dragonfly to compile.

See sdk/cpp/example on how to compile a UDF to wasm and executed in dragonfly via CALLWASM command

@@ -1,3 +1,6 @@
[submodule "helio"]
path = helio
url = https://github.com/romange/helio.git
[submodule "wasmtime"]
path = wasmtime
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should really use add_third_party. I couldn't make it work and I didn't want to loose time since this is just a prototype merely to show how we embed wasmtime, how we export API functions to sdk users, and how we consume wasm binaries in dragonfly

@@ -77,6 +77,11 @@ cxx_link(dragonfly_lib dfly_transaction dfly_facade redis_lib awsv2_lib jsonpath
http_client_lib absl::random_random TRDP::jsoncons ${ZSTD_LIB} TRDP::lz4
TRDP::croncpp TRDP::flatbuffers)

add_library(wasmtime STATIC IMPORTED)

target_include_directories(dragonfly_lib PRIVATE ${CMAKE_SOURCE_DIR}/wasmtime/crates/c-api/include)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a hack


std::string mod = "dragonfly";
std::string export_f = "hello";
wasm_valtype_vec_t arg_types;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need proper APIs for all of these C functions :)

@kostasrim kostasrim self-assigned this May 10, 2024
@kostasrim kostasrim closed this May 16, 2024
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

1 participant