Function stream is an event-streaming function platform based on Apache Pulsar and WebAssembly. It enables efficient and scalable processing of data streams by leveraging the power of WebAssembly. Function Stream provides seamless integration with Apache Pulsar, allowing users to take full advantage of its robust messaging capabilities.
Function Stream is composed of three main components: the WebAssembly runtime engine, the Pulsar client, and the
Function Stream service. The following figure shows the overview of the Function Stream architecture.

The WebAssembly runtime engine is responsible for executing the WebAssembly modules that implement the stream processing logic. The runtime engine supports an interface for the underlying wasm runtime library. We use wazero as the WebAssembly runtime library, as they are both fast and lightweight. The WebAssembly runtime engine communicates with the Pulsar client through standard IO and file systems.
The Pulsar client is responsible for consuming and publishing the messages from and to the Apache Pulsar cluster. We use Pulsar Go client, which is a pure go implementation of the pulsar client library, to interact with the Pulsar brokers. The Pulsar client handles the data schema, the message metadata, and the processing guarantees of the messages.
The Function Stream service is responsible for managing the lifecycle and coordination of the WebAssembly instances.
The Function Stream project is organized as follows:
├── LICENSE # The license for Function Stream
├── Makefile # Contains build automation and commands
├── README.md # README file for the project
├── benchmark # Contains benchmarking tools or results
├── bin # Contains compiled binary files
├── cmd # Contains the command line executable source files
├── common # Contains common utilities and libraries used across the project
├── docs # Documentation for the project
├── examples # Example configurations, scripts, and other reference materials
├── go.mod # Defines the module's module path and its dependency requirements
├── go.sum # Contains the expected cryptographic checksums of the content of specific module versions
├── fs # Core library files for Function Stream
├── license-checker # Tools related to checking license compliance
├── openapi.yaml # API definition file
├── perf # Performance testing scripts
├── restclient # REST client library
├── server # Server-side application source files
└── tests # Contains test scripts and test data
To compile Function Stream, use this command:
make build-all
This creates the function-stream binary program and example wasm files in the bin directory,
like bin/example_basic.wasm.
You have two ways to start the function stream server.
Use this command to start the function stream server:
bin/function-stream server
We'll use example_basic.wasm as an example wasm file. This function increases the money by 1. See the
code here.
After starting the server, create a function with this command:
bin/function-stream client create -n example -a "bin/example_basic.wasm" -i example-input -o example-output -r 1
This creates a function named example using example_basic.wasm. It takes messages from example-input, produces
messages to example-output, and runs with 1 replica.
After creating the function, consume a message from the output topic with this command:
bin/function-stream client consume -n example-output
In a new terminal, produce a message to the input topic with this command:
bin/function-stream client produce -n example-input -c '{"name":"rbt","money":2}'
You'll see this log:
Event produced
In the terminal where you consume the message from the output topic, you'll see this log:
"{\"name\":\"rbt\",\"money\":3,\"expected\":0}"
After testing, delete the function with this command:
bin/function-stream client delete -n example
We're happy to receive contributions from the community. If you find a bug or have a feature request, please open an issue or submit a pull request.
This project is licensed under the Apache License 2.0.
$ claude mcp add function-stream \
-- python -m otcore.mcp_server <graph>