reifydb_core/interceptor/
transaction.rs

1// Copyright (c) reifydb.com 2025
2// This file is licensed under the AGPL-3.0-or-later, see license.md file
3
4use std::marker::PhantomData;
5
6use crate::{
7	CommitVersion, define_api_function, define_closure_interceptor, define_interceptor, interface::TransactionId,
8};
9
10// PRE COMMIT
11define_interceptor!(
12	context: PreCommitContext<T>,
13	trait: PreCommitInterceptor,
14	fields: {
15		txn: &'a mut T}
16);
17
18define_closure_interceptor!(ClosurePreCommitInterceptor, PreCommitInterceptor, PreCommitContext, with_transaction);
19
20define_api_function!(
21	pre_commit,
22	ClosurePreCommitInterceptor<T, F>,
23	PreCommitContext<T>
24);
25
26// POST COMMIT
27define_interceptor!(
28	context: PostCommitContext,
29	trait: PostCommitInterceptor<T>,
30	fields: {
31		id: TransactionId,
32		version: CommitVersion,
33		changes: TransactionalDefChanges,
34		row_changes: Vec<RowChange>}
35);
36
37define_closure_interceptor!(
38	ClosurePostCommitInterceptor,
39	PostCommitInterceptor,
40	PostCommitContext,
41	no_transaction_param
42);
43
44define_api_function!(post_commit, ClosurePostCommitInterceptor<F>, PostCommitContext);
45
46use crate::{
47	impl_register_interceptor,
48	interface::{RowChange, TransactionalDefChanges},
49};
50
51impl_register_interceptor!(
52	ClosurePreCommitInterceptor<T, F>,
53	PreCommitContext<T>,
54	PreCommitInterceptor,
55	pre_commit
56);
57
58impl_register_interceptor!(ClosurePostCommitInterceptor<F>, PostCommitContext, PostCommitInterceptor<T>, post_commit);