Skip to main content

Overview

Functions are the core building blocks of III applications. A function is a piece of code that can be invoked remotely by other workers or triggers.

Registering Functions

register_function

Register a function with the default configuration.
impl Into<String>
required
Unique identifier for the function
F
required
Async function that processes input and returns a result. The handler receives a serde_json::Value and must return Result<Value, IIIError>.
Example:

register_function_with_description

Register a function with a description.
impl Into<String>
required
Unique identifier for the function
impl Into<String>
required
Human-readable description of what the function does
F
required
Async function handler
Example:

register_function_with

Register a function with full configuration options.
RegisterFunctionMessage
required
Complete function registration message with all metadata
F
required
Async function handler
Example:

HTTP Functions

HTTP functions are proxy functions that invoke external HTTP endpoints.

register_http_function

Register a function that proxies to an HTTP endpoint.
impl Into<String>
required
Unique identifier for the function
HttpInvocationConfig
required
HTTP configuration including URL, method, headers, and authentication
Result<HttpFunctionRef, IIIError>
Reference that can be used to unregister the function
Example:

Function Context

Every function handler runs within a context that provides logging and tracing capabilities.

Accessing Context

Use get_context() to access the current function’s context:

Context Structure

The Context struct provides:
  • logger: Logger instance scoped to the current function
  • span: Active tracing span (when otel feature is enabled)

Function Discovery

list_functions

List all registered functions in the engine.
Result<Vec<FunctionInfo>, IIIError>
List of all registered functions with their metadata
Example:

on_functions_available

Subscribe to notifications when functions become available.
F
required
Callback invoked whenever functions are registered or updated
FunctionsAvailableGuard
Guard that automatically unsubscribes when dropped
Example:

Types

RegisterFunctionMessage

HttpInvocationConfig

HttpMethod

FunctionInfo

See Also