SuperAPI AI 工具集

streamling-plugin-basics

编程与开发

查看项目

更新于 10-16 05:49

技能介绍

用途:指导在 Rust 中新建 streamling 插件 crate(source、sink、transform、preprocessor、UDF 或 side output),以及配置注册宏与初始化。

主要能力:说明插件是运行时经稳定 ABI(abi_stable)加载的独立 cdylib,可注册六类组件;给出 crate 配置(cdylib + rlib、依赖 streamling-plugin、abi_stable、async-trait、tokio、tracing、arrow、serde);列出注册宏(register_plugin_source!/transform!/sink!/preprocessor!/udf!/udf_fn!/side_output!,set_plugin_input_buffer!/set_plugin_output_buffer!)及 init_plugin_with_async_runtime!() 必须在底部调用一次;给出各类 new() 构造参数的固定顺序与返回值;说明 initialize、process_batch、process_checkpoint_marker、process_checkpoint_finalizer、terminate 生命周期及 SupportsGracefulShutdown 要求;提供异步运行时、选项与密钥(环境变量优先)、指标记录、状态后端、错误枚举(PluginInitializationError、PluginError)等通用工具。

使用方式:新建 Cargo crate,设置 crate-type = ["cdylib", "rlib"],依赖 streamling-plugin,在 lib.rs 中注册组件并调用 init_plugin_with_async_runtime!();按宏约定实现 new() 与组件 trait。

限制与注意:new() 参数顺序错误无法编译;缺少 init 宏则模块无可加载导出;process_batch 中 panic 会崩溃工作线程,应返回 Err;密钥不应写在 YAML 明文;对用户选项避免 unwrap;持久化进度应放在 process_checkpoint_finalizer 而非 process_batch。其他细节暂未提供。