Skip to main content

CLI invoke command

Use the invoke command to invoke a function. The command requires both a promise id and the name of the function that should run.

resonate invoke <promise-id> --func <function-name> [flags]

Flags

  • --func (required): Name of the function to execute.
  • --arg: Provide a positional argument. Repeat the flag to send multiple arguments. Values are passed as strings.
  • --json-args: Provide an entire JSON array of arguments. Useful for complex payloads that would be cumbersome to express with repeated --arg flags.
  • --timeout: How long to wait for the invocation to complete before timing out (for example 30s, 5m, or 1h).
  • --target: Override the default target when invoking the function. Supply a URI such as poll://any@default to steer the invocation to a specific worker group.

Examples

Invoke a function that adds two numbers:

resonate invoke promise-id --func add --arg 1 --arg 2 --arg "a string"

Invoke a function with a timeout and an explicit target:

resonate invoke promise-id --func process --arg data1 --arg 5 --timeout 1h --target "poll://any@default"

Invoke a function with JSON arguments:

resonate invoke promise-id --func process --json-args '[{"key": "value"}, {"num": 42}]'