wasm

command
v2.44.0-RC1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2023 License: Apache-2.0, BSD-3-Clause, MIT Imports: 11 Imported by: 0

README

Overview

wasm is an EXPERIMENTAL simple example that loads and executes a wasm file function. greet.wasm, Cargo.toml and greet.rs were copied from the example provided by the wazero library: https://github.com/tetratelabs/wazero/blob/v1.0.0-pre.3/examples/allocation/rust/greet.go

Usage

To run this example in various runners, the following assumes:

OUTPUT=<path to output i.e. /tmp/example/output>
git clone https://github.com/apache/beam
BEAM_HOME=$(pwd)/beam
cd $BEAM_HOME/sdks

Direct Runner execution

To execute this example on the direct runner:

go run ./go/examples/wasm --output=$OUTPUT

The following describes how to execute this example on the flink portable runner.

REQUIREMENTS:
0. Set OUTPUT to a Cloud storage bucket path

The example below shows Google Cloud Storage.

OUTPUT=gs://<my bucket>/greet
cd $BEAM_HOME
./gradlew :runners:flink:properties --property flink_versions

Expected output should include the following, from which you acquire the latest flink runner version.

'flink_versions: 1.12,1.13,1.14,1.15'
FLINK_VERSION=1.15
cd $BEAM_HOME
./gradlew :runners:flink:$FLINK_VERSION:job-server:runShadow

Note the JobService host and port from the output, similar to:

INFO: JobService started on localhost:8099
4. Set the JOB_SERVICE variable from the aforementioned output
JOB_SERVICE=localhost:8099
cd $BEAM_HOME/sdks
go run ./go/examples/wasm --runner=universal --endpoint=$JOB_SERVICE --output=$OUTPUT --environment_config=apache/beam_go_sdk:latest

Dataflow Runner

The following describes how to execute this example on Dataflow.

REQUIREMENTS:
1. Set OUTPUT to a Cloud storage bucket path

The example below shows Google Cloud Storage.

OUTPUT=gs://<my bucket>/greet
2. Set additional variables
PROJECT=<project id>
REGION=<region>
STAGING=gs://<my bucket>/staging
NETWORK=<network>
SUBNETWORK=regions/$REGION/subnetworks/<subnetwork>
3. Execute this example using Dataflow
cd $BEAM_HOME/sdks
go run ./go/examples/wasm --runner=dataflow --output=$OUTPUT --environment_config=apache/beam_go_sdk:latest \
    --project=$PROJECT --region=$REGION --network=$NETWORK --subnetwork=$SUBNETWORK --staging_location=$STAGING

Documentation

Overview

wasm is an EXPERIMENTAL simple example that loads and executes a wasm file function. greet.wasm, Cargo.toml and greet.rs were copied from the example provided by the wazero library: https://github.com/tetratelabs/wazero/blob/v1.0.0-pre.3/examples/allocation/rust/greet.go

New Concepts: 1. Load a wasm file compiled from: cargo build --release --target wasm32-unknown-unknown 2. Execute a wasm function within a DoFn

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL