Skip to main content
Version: 4.0.x

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.

  1. Prepare a Go function file.

  2. Build the Go function.

     go build <your Go function filename>.go
  3. Run the Go function with the following command.

     bin/pulsar-admin functions localrun \
    --go [absolute path to your go function]
    --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
    ...