Implementation:ArroyoSystems Arroyo Udf Api Types
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Streaming, UDF, API |
| Last Updated | 2026-02-08 08:00 GMT |
Overview
Defines the API-level types for user-defined function (UDF) management, including creation, validation, and storage representations for both Rust and Python UDFs.
Description
This module provides the types for the UDF management API:
- Udf -- a lightweight UDF reference used within pipeline definitions, containing a definition string and language (Rust or Python).
- UdfLanguage -- an enum with variants Python and Rust (default). Derives Display and EnumString from strum for serialization and parsing.
- ValidateUdfPost -- request type for validating a UDF definition before registration.
- UdfValidationResult -- response type with the parsed udf_name and any validation errors.
- UdfPost -- request for creating/updating a global UDF with prefix, language, definition, and optional description.
- GlobalUdf -- the persisted representation of a registered UDF with id, prefix, name, language, timestamps, definition, description, and optional dylib_url pointing to the compiled shared library.
Usage
Use these types when implementing or consuming the UDF endpoints in the Arroyo REST API for registering, validating, and managing user-defined functions.
Code Reference
Source Location
- Repository: ArroyoSystems_Arroyo
- File: crates/arroyo-rpc/src/api_types/udfs.rs
Signature
pub struct Udf { pub definition: String, pub language: UdfLanguage }
pub enum UdfLanguage { Python, Rust }
pub struct ValidateUdfPost { pub definition: String, pub language: UdfLanguage }
pub struct UdfValidationResult { pub udf_name: Option<String>, pub errors: Vec<String> }
pub struct UdfPost {
pub prefix: String,
pub language: UdfLanguage,
pub definition: String,
pub description: Option<String>,
}
pub struct GlobalUdf {
pub id: String,
pub prefix: String,
pub name: String,
pub language: UdfLanguage,
pub created_at: u64,
pub updated_at: u64,
pub definition: String,
pub description: Option<String>,
pub dylib_url: Option<String>,
}
Import
use arroyo_rpc::api_types::udfs::{Udf, UdfLanguage, UdfPost, GlobalUdf, ValidateUdfPost, UdfValidationResult};
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| definition | String | Yes | UDF source code (Rust or Python) |
| language | UdfLanguage | No (defaults to Rust) | Programming language of the UDF |
| prefix | String | Yes (for UdfPost) | Namespace prefix for the UDF |
Outputs
| Name | Type | Description |
|---|---|---|
| GlobalUdf | GlobalUdf | Persisted UDF with compilation artifacts |
| UdfValidationResult | UdfValidationResult | Parsed name and any validation errors |
Usage Examples
use arroyo_rpc::api_types::udfs::{UdfPost, UdfLanguage};
let udf_request = UdfPost {
prefix: "my_udfs".to_string(),
language: UdfLanguage::Rust,
definition: r#"
fn my_transform(x: i64) -> i64 {
x * 2
}
"#.to_string(),
description: Some("Doubles the input value".to_string()),
};
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment