Skip to main content

drasi_reaction_storedproc_postgres/
lib.rs

1#![allow(unexpected_cfgs)]
2// Copyright 2025 The Drasi Authors.
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//     http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16//! PostgreSQL Stored Procedure reaction plugin for Drasi
17//!
18//! This plugin implements reactions that invoke PostgreSQL stored procedures when
19//! continuous query results change. It supports different procedures for
20//! ADD, UPDATE, and DELETE operations using Handlebars templates.
21//!
22//! # Example
23//!
24//! ```rust,ignore
25//! use drasi_reaction_storedproc_postgres::{PostgresStoredProcReaction, QueryConfig, TemplateSpec};
26//!
27//! let reaction = PostgresStoredProcReaction::builder("user-sync")
28//!     .with_connection("localhost", 5432, "mydb", "postgres", "password")
29//!     .with_query("user-changes")
30//!     .with_default_template(QueryConfig {
31//!         added: Some(TemplateSpec::new("CALL add_user(@after.id, @after.name, @after.email)")),
32//!         updated: Some(TemplateSpec::new("CALL update_user(@after.id, @after.name, @after.email)")),
33//!         deleted: Some(TemplateSpec::new("CALL delete_user(@before.id)")),
34//!     })
35//!     .build()?;
36//! ```
37
38pub mod config;
39pub mod descriptor;
40pub mod executor;
41pub mod parser;
42pub mod reaction;
43
44pub use config::{PostgresStoredProcReactionConfig, QueryConfig, TemplateSpec};
45pub use reaction::PostgresStoredProcReaction;
46
47/// Dynamic plugin entry point.
48///
49/// Dynamic plugin entry point.
50#[cfg(feature = "dynamic-plugin")]
51drasi_plugin_sdk::export_plugin!(
52    plugin_id = "storedproc-postgres-reaction",
53    core_version = env!("CARGO_PKG_VERSION"),
54    lib_version = env!("CARGO_PKG_VERSION"),
55    plugin_version = env!("CARGO_PKG_VERSION"),
56    source_descriptors = [],
57    reaction_descriptors = [descriptor::PostgresStoredProcReactionDescriptor],
58    bootstrap_descriptors = [],
59);