This section introduces how to develop and pacakge WASM Pulsar functions to use on StreamNative cloud.
The WASM runtime is still in private preview stage, If you want to try it out or have any questions, please submit a ticket to the support team.
Develop
The WASM runtime is using WasmEdge, theoretically, you can use any languages which
can be compiled to a WASM module to write your functions, below is an example using Rust:
Feature Matrix
The WASM runtime doesn’t support full features comparing to Java runtime, and it’s still in developing, below is the matrix:
Users can implement the Schema themselves since we are passing and expecting []byte to/from the users’ function, so leave ? here.
Output Arguments
Context
WASM runtime doesn’t support the Context features at all for now.
Other
Package
You need to compile the function to a .wasm module first before creating Pulsar Functions.
Deploy
After creating a cluster, set up your environment and develop&package your function, you can use the snctl, pulsarctl, pulsar-admin command, the REST API, or terraform to deploy a Pulsar function to your cluster.
You can create a WASM Pulsar function by using a local .wasm file or an uploaded Pulsar functions package(recommend).
(Optional) Upload your function file to Pulsar
It’s recommended to upload your function file to Pulsar before you create a function. Since you can add a version suffix to the package.
snctl
Pulsarctl
Pulsar-admin
Upload packagesYou should see the following output: You need to set the context for Pulsarctl first:Replace the placeholder variables with the actual values that you can get when setting up client tools.
context-name: any name you want
admin-service-url: the HTTP service URL of your Pulsar cluster.
privateKey: the path to the downloaded OAuth2 key file.
issuerUrl: the URL of the OAuth2 issuer.
audience: the Uniform Resource Name (URN), which is a combination of the urn:sn:pulsar, your organization name, and your Pulsar instance name.
Upload packagesYou should see the following output: Replace the placeholder variables with the actual values that you can get when setting up client tools.
admin-url: the HTTP service URL of your Pulsar cluster.
privateKey: the path to the downloaded OAuth2 key file.
issuerUrl: the URL of the OAuth2 issuer.
audience: the Uniform Resource Name (URN), which is a combination of the urn:sn:pulsar, your organization name, and your Pulsar instance name.
You should see the following output:
Create
snctl
Pulsarctl
Pulsar-admin
Terraform
REST API
Only Pulsar 4.0.x clusters running version 4.0.10.6 or later, or Pulsar 4.2.x clusters running version 4.2.1.4 or later, support the --sn-service-account flag.You can use --as-service-account instead of --sn-service-account if you are using other versions of Pulsar clusters.
Since Pulsar doesn’t support WASM runtime, we need to use --py to specify the function file and specify the --custom-runtime-options '{"genericKind": "wasm"}' to make it work.
You should see something like this:Since Pulsar doesn’t support WASM runtime, we need to use --py to specify the function file and specify the --custom-runtime-options '{"genericKind": "wasm"}' to make it work.
You should see something like this:Since Pulsar doesn’t support WASM runtime, we need to use --py to specify the function file and specify the --custom-runtime-options '{"genericKind": "wasm"}' to make it work.
You should see something like this:Create your terraform yaml file:Since Pulsar doesn’t support WASM runtime, we need to use --py to specify the function file and specify the --custom-runtime-options '{"genericKind": "wasm"}' to make it work.
Init the terraform provider in the same dir of your .tf file if you haven’t done it:You should see something like this:Create the function:You should see something like:After enter “yes”, you should see the following:Replace the placeholder variables with the actual values that you can get when setting up client tools.
admin-url: the HTTP service URL of your Pulsar cluster.
privateKey: the path to the downloaded OAuth2 key file.
issuerUrl: the URL of the OAuth2 issuer.
audience: the Uniform Resource Name (URN), which is a combination of the urn:sn:pulsar, your organization name, and your Pulsar instance name.
If you would like to create a function configuration using the REST API you can
do so using CURL.Since Pulsar doesn’t support WASM runtime, we need to use --py to specify the function file and specify the --custom-runtime-options '{"genericKind": "wasm"}' to make it work.
The function is assumed to be already uploaded at this point. If you have not
uploaded the function, change the url parameter to be your local filepath.
This will look something like the following. You should see something like this:Replace the placeholder variables with the actual values that you can get when setting up client tools.
WEB_SERVICE_URL: the HTTPS service URL of your Pulsar cluster.
TOKEN: a valid token to interact with your Pulsar cluster.
FUNCTION_NAME: the name of your function.
FUNCTION_VERSION: the version of your function you want to deploy e.g. 1.12.
For details about Pulsar function configurations, see Pulsar function configurations.
What’s next?