Expand description
A Rust implementation of Kapacitor User-Defined Functions (UDFs).
This crate provides a framework for creating and managing UDFs that can be integrated with Kapacitor, a real-time streaming data processing engine. It includes functionality for handling communication protocols, managing data flow, and implementing custom data processing logic.
§Modules
proto
: Contains the generated Protocol Buffers code for communication with Kapacitor.agent
: Implements theAgent
struct, which manages the lifecycle and communication of a UDF.io
: Provides utilities for reading and writing Protocol Buffer messages.server
: Implements the server-side logic for handling UDF connections.traits
: Defines theHandler
trait, which users implement to create custom UDFs.
§Examples
To create a custom UDF, implement the Handler
trait and use the Agent
to manage its lifecycle:
use my_udf_crate::{traits::Handler, agent::Agent, proto};
use async_trait::async_trait;
use std::io;
struct MyUDF;
#[async_trait]
impl Handler for MyUDF {
// Implement Handler methods...
}
let mut agent = Agent::new(/* provide input and output */);
agent.set_handler(Some(Box::new(MyUDF)));
agent.start().await?;
Modules§
- agent
- io
- I/O utilities for handling protocol buffer messages over streams.
- proto
- Generated Protocol Buffers code for Kapacitor UDF communication.
- socket_
server - Server module for handling Unix socket connections in a Kapacitor UDF context.
- stdio_
server - Server module for handling standard input/output connections in a Kapacitor UDF context.
- traits