SuperAPI AI 工具集

streamling-advanced-plugins

数据与分析

查看项目

更新于 10-16 05:49

技能介绍

用途:在 streamling 插件基础上扩展三类组件,并可与源、转换、接收器混合注册于同一 cdylib。

预处理器:在 streamling 解析前改写管道拓扑 YAML,用于注入默认选项、展开简写数据集名。构造函数只接收 options,无 schema/rt/state/metrics。用 register_plugin_preprocessor!("my_plugin", "defaults", DefaultsPreprocessor) 注册,按注册顺序执行,后者可见前者输出。限制:不得覆盖用户已设字段,只填空缺;解析失败须转 PluginError::Internal,不得 panic。

UDF:以 DataFusion 标量函数暴露给 SQL(SELECT my_func(col) FROM ...),实现 ScalarUDFImpl 并用 register_plugin_udf!(MyFunc) 或 legacy 的 register_plugin_udf_fn! 注册。完整 API 与示例见 streamling-udf-plugin。

旁路输出:观察所有源的数据,不加入管道、不改记录,用于计数、水位、心跳等。实现 SideOutputPlugin,process_batch 与 shutdown 为同步,返回 Result<(), String>(非 PluginError)。用 register_plugin_side_output!("monitor", MonitorSideOutput) 注册,实例按源自动创建,无需配 from:。

混合注册规则:整个 crate 仅底部一个 init_plugin_with_async_runtime!();set_plugin_output_buffer!/set_plugin_input_buffer! 可选、按组件、需用完整 plugin.id;每个组件独立模块,仅 lib.rs 放注册列表。

低层手动 FFI:仅当宏无法表达(组件在标准闭包外构造、自定义通道接线)时使用 abi_stable 与 PluginModule ABI,手写 init、create、udf_descriptors、side_output_descriptors 及 export_root_module。否则应优先用宏以保证 ABI 安全。

适用场景:需要改写拓扑配置、在 SQL 中调用自定义函数、或旁路监控各源数据时。限制:资料未提供具体收费、平台信息与完整安装命令,暂未提供。