Skip to main content

Crate drasi_reaction_storedproc_postgres

Crate drasi_reaction_storedproc_postgres 

Source
Expand description

PostgreSQL Stored Procedure reaction plugin for Drasi

This plugin implements reactions that invoke PostgreSQL stored procedures when continuous query results change. It supports different procedures for ADD, UPDATE, and DELETE operations using Handlebars templates.

§Example

use drasi_reaction_storedproc_postgres::{PostgresStoredProcReaction, QueryConfig, TemplateSpec};

let reaction = PostgresStoredProcReaction::builder("user-sync")
    .with_connection("localhost", 5432, "mydb", "postgres", "password")
    .with_query("user-changes")
    .with_default_template(QueryConfig {
        added: Some(TemplateSpec::new("CALL add_user(@after.id, @after.name, @after.email)")),
        updated: Some(TemplateSpec::new("CALL update_user(@after.id, @after.name, @after.email)")),
        deleted: Some(TemplateSpec::new("CALL delete_user(@before.id)")),
    })
    .build()?;

Re-exports§

pub use config::PostgresStoredProcReactionConfig;
pub use reaction::PostgresStoredProcReaction;

Modules§

config
Configuration for the PostgreSQL Stored Procedure reaction.
descriptor
Descriptor for the PostgreSQL stored procedure reaction plugin.
executor
PostgreSQL executor for stored procedure invocation.
parser
Parameter parser for stored procedure commands.
reaction
PostgreSQL Stored Procedure reaction implementation.

Structs§

QueryConfig
Configuration for query-specific template-based output.
TemplateSpec
Specification for template-based output.