Package Go Functions
note
Currently, Go functions can be implemented only using SDK and the interface of functions is exposed in the form of SDK. Before using Go functions, you need to import github.com/apache/pulsar/pulsar-function-go/pf
.
To package a Go function, complete the following steps.
Prepare a Go function file.
Build the Go function.
go build <your Go function filename>.go
Copy the Go function file to the Pulsar image.
docker exec -it [CONTAINER ID] /bin/bash
docker cp <your go function path> CONTAINER ID:/pulsar
Run the Go function with the following command.
bin/pulsar-admin functions localrun \
--go [your go function path]
--inputs [input topics] \
--output [output topic] \
--tenant [default:public] \
--namespace [default:default] \
--name [custom unique go function name]
The following log indicates that the Go function starts successfully.
...
07:55:03.724 [main] INFO org.apache.pulsar.functions.runtime.ProcessRuntime - Started process successfully
...