ArangoDB Events
A library to add triggers to your ArangoDB database, when events occur (insert, update, delete etc.) on your
collections.

Documentation
Features
async
Enables asynchronous Handler::call
method
Installation
Add the crate to your Cargo.toml
:
arangodb_events_rs = "0.1.6"
Usage
use arangodb_events_rs::api::DocumentOperation;
use arangodb_events_rs::{Handler, Trigger, HandlerContextFactory};
pub struct GlobalHandler;
pub struct GlobalHandlerContext {
pub data: u8,
}
impl Handler for GlobalHandler {
type Context = GlobalHandlerContext;
fn call(ctx: &GlobalHandlerContext, doc: &DocumentOperation) {
println!("{}", ctx.data); }
}
#[tokio::main]
async fn main() {
let mut trigger = Trigger::new_auth(
"http://localhost:8529/",
"database",
TriggerAuthentication::new("user", "password"),
);
trigger.subscribe::<GlobalHandler>(
HandlerEvent::InsertOrReplace,
HandlerContextFactory::from(GlobalHandlerContext {
data: 10,
})
);
trigger.subscribe_to::<AccountHandler>(
HandlerEvent::Remove,
"accounts",
HandlerContextFactory::from(AccountHandlerContext {
data: 50,
})
);
trigger
.init()
.await
.expect("Error initializing ArangoDB Trigger");
loop {
trigger
.listen()
.await
.expect("Error on Trigger listener loop");
}
}