Expand description
Write Paganel plugins in Rust.
Paganel is a data migration engine. A plugin runs inside its WASM sandbox as a transform (compute a column), a filter (accept or reject a row), a source (produce rows) or a sink (consume them). Pick the matching attribute macro and write an ordinary function: the macro emits the ABI the host expects.
use paganel_plugin_sdk::{paganel_transform, PluginInput, PluginResult};
#[paganel_transform(
name = "adder",
version = "1.0.0",
output = "f64",
input = [
{ name = "a", type = "f64", nullable = false },
{ name = "b", type = "f64", nullable = false },
]
)]
fn add(inputs: Vec<PluginInput>) -> PluginResult<Vec<f64>> {
inputs
.iter()
.map(|input| Ok(input.get_f64("a")? + input.get_f64("b")?))
.collect()
}Build with --target wasm32-wasip1 --release and a cdylib crate type.
Your function receives a whole batch, not one row: the host crosses the WASM boundary once per batch, which is why a native Rust plugin runs close to the no-plugin rate. Plugins execute under fuel, memory and timeout caps with no filesystem or network access unless the pipeline grants it.
§Where to look
Re-exports§
pub use error::PluginError;pub use error::PluginErrorCode;pub use error::PluginResult;pub use filter::FilterDecision;pub use input::PluginInput;pub use output::PluginOutput;pub use record::FieldValue;pub use record::Record;pub use schema::PluginField;pub use schema::PluginMetadata;pub use schema::PluginType;pub use sink::PluginBatch;pub use sink::SinkConfig;pub use sink::WriteResult;pub use source::SourceConfig;pub use source::SourcePage;pub use value::Value;pub use host::env::env_get;pub use host::fs::fs_read;pub use host::fs::fs_read_to_string;pub use host::fs::fs_write;pub use host::http::HttpResponse;pub use host::http::http_get;pub use host::http::http_post;pub use host::kv::kv_get;pub use host::kv::kv_set;pub use host::log::log_debug;pub use host::log::log_error;pub use host::log::log_info;pub use host::log::log_warn;pub use host::metrics::metric_counter;pub use host::metrics::metric_gauge;pub use runtime::pack::pack;pub use runtime::pack::unpack;
Modules§
- columnar
- Guest half of the
columnar_v1binary wire format. - error
- exchange
- filter
- host
- input
- output
- record
- runtime
- schema
- sink
- source
- value
Structs§
- Plugin
Config - Static configuration delivered to a plugin at initialize time, parsed from
the PPL
plugin "x" { config { ... } }block.
Functions§
- config
- Access the plugin’s static configuration.
- sink_
config - Access the sink plugin’s static configuration. Returns an error if the
plugin’s
__paganel_initializehasn’t run yet. - source_
config - Access the source plugin’s static configuration. Returns an error if the
plugin’s
__paganel_initializehasn’t run yet.
Attribute Macros§
- paganel_
filter - Attribute macro for filter plugins.
- paganel_
sink - Attribute macro for sink plugins.
- paganel_
source - Attribute macro for source plugins.
- paganel_
transform - Attribute macro for transform plugins.