Deploy a function in localrun mode

When you deploy a function in localrun mode, it runs on the machine where you enter the commands – on your laptop, for example, or in an AWS EC2 instance.

You can use the localrun command to run a single instance of a function. To run multiple instances, you can use the localrun command multiple times.

The following is an example of how to use the localrun command.

  1. bin/pulsar-admin functions localrun \
  2. --py myfunc.py \
  3. --classname myfunc.SomeFunction \
  4. --inputs persistent://public/default/input-1 \
  5. --output persistent://public/default/output-1

Deploy a function in localrun mode - 图1note

In localrun mode, Java functions use thread runtime; Python and Go functions use process runtime.

By default, the function connects with a Pulsar cluster running on the same machine via a local broker service URL. If you want to connect it to a non-local Pulsar cluster, you can specify a different broker service URL using the --brokerServiceUrl flag.

  1. bin/pulsar-admin functions localrun \
  2. --broker-service-url pulsar://my-cluster-host:6650 \
  3. # Other function parameters