Skip to main content

reifydb_core/interface/catalog/
change.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2025 ReifyDB
3
4use reifydb_type::Result;
5
6use crate::{
7	interface::catalog::{
8		authentication::Authentication,
9		binding::Binding,
10		config::Config,
11		dictionary::Dictionary,
12		flow::Flow,
13		handler::Handler,
14		identity::{GrantedRole, Identity, Role},
15		migration::{Migration, MigrationEvent},
16		namespace::Namespace,
17		policy::Policy,
18		procedure::Procedure,
19		ringbuffer::RingBuffer,
20		series::Series,
21		shape::ShapeId,
22		sink::Sink,
23		source::Source,
24		sumtype::SumType,
25		table::Table,
26		test::Test,
27		view::View,
28	},
29	row::RowTtl,
30};
31
32/// Trait for tracking configuration changes during a transaction.
33pub trait CatalogTrackConfigChangeOperations {
34	fn track_config_set(&mut self, pre: Config, post: Config) -> Result<()>;
35}
36
37/// Trait for tracking table definition changes during a transaction.
38pub trait CatalogTrackTableChangeOperations {
39	fn track_table_created(&mut self, table: Table) -> Result<()>;
40
41	fn track_table_updated(&mut self, pre: Table, post: Table) -> Result<()>;
42
43	fn track_table_deleted(&mut self, table: Table) -> Result<()>;
44}
45
46/// Trait for tracking namespace definition changes during a transaction.
47pub trait CatalogTrackNamespaceChangeOperations {
48	fn track_namespace_created(&mut self, namespace: Namespace) -> Result<()>;
49
50	fn track_namespace_updated(&mut self, pre: Namespace, post: Namespace) -> Result<()>;
51
52	fn track_namespace_deleted(&mut self, namespace: Namespace) -> Result<()>;
53}
54
55/// Trait for tracking flow definition changes during a transaction.
56pub trait CatalogTrackFlowChangeOperations {
57	fn track_flow_created(&mut self, flow: Flow) -> Result<()>;
58
59	fn track_flow_updated(&mut self, pre: Flow, post: Flow) -> Result<()>;
60
61	fn track_flow_deleted(&mut self, flow: Flow) -> Result<()>;
62}
63
64/// Trait for tracking view definition changes during a transaction.
65pub trait CatalogTrackViewChangeOperations {
66	fn track_view_created(&mut self, view: View) -> Result<()>;
67
68	fn track_view_updated(&mut self, pre: View, post: View) -> Result<()>;
69
70	fn track_view_deleted(&mut self, view: View) -> Result<()>;
71}
72
73/// Trait for tracking dictionary definition changes during a transaction.
74pub trait CatalogTrackDictionaryChangeOperations {
75	fn track_dictionary_created(&mut self, dictionary: Dictionary) -> Result<()>;
76
77	fn track_dictionary_updated(&mut self, pre: Dictionary, post: Dictionary) -> Result<()>;
78
79	fn track_dictionary_deleted(&mut self, dictionary: Dictionary) -> Result<()>;
80}
81
82/// Trait for tracking series definition changes during a transaction.
83pub trait CatalogTrackSeriesChangeOperations {
84	fn track_series_created(&mut self, series: Series) -> Result<()>;
85
86	fn track_series_updated(&mut self, pre: Series, post: Series) -> Result<()>;
87
88	fn track_series_deleted(&mut self, series: Series) -> Result<()>;
89}
90
91/// Trait for tracking ringbuffer definition changes during a transaction.
92pub trait CatalogTrackRingBufferChangeOperations {
93	fn track_ringbuffer_created(&mut self, ringbuffer: RingBuffer) -> Result<()>;
94
95	fn track_ringbuffer_updated(&mut self, pre: RingBuffer, post: RingBuffer) -> Result<()>;
96
97	fn track_ringbuffer_deleted(&mut self, ringbuffer: RingBuffer) -> Result<()>;
98}
99
100/// Trait for tracking sum type definition changes during a transaction.
101pub trait CatalogTrackSumTypeChangeOperations {
102	fn track_sumtype_created(&mut self, sumtype: SumType) -> Result<()>;
103
104	fn track_sumtype_updated(&mut self, pre: SumType, post: SumType) -> Result<()>;
105
106	fn track_sumtype_deleted(&mut self, sumtype: SumType) -> Result<()>;
107}
108
109/// Trait for tracking procedure definition changes during a transaction.
110pub trait CatalogTrackProcedureChangeOperations {
111	fn track_procedure_created(&mut self, procedure: Procedure) -> Result<()>;
112
113	fn track_procedure_updated(&mut self, pre: Procedure, post: Procedure) -> Result<()>;
114
115	fn track_procedure_deleted(&mut self, procedure: Procedure) -> Result<()>;
116}
117
118/// Trait for tracking test definition changes during a transaction.
119pub trait CatalogTrackTestChangeOperations {
120	fn track_test_created(&mut self, test: Test) -> Result<()>;
121
122	fn track_test_deleted(&mut self, test: Test) -> Result<()>;
123}
124
125/// Trait for tracking handler definition changes during a transaction.
126pub trait CatalogTrackHandlerChangeOperations {
127	fn track_handler_created(&mut self, handler: Handler) -> Result<()>;
128
129	fn track_handler_deleted(&mut self, handler: Handler) -> Result<()>;
130}
131
132/// Trait for tracking identity definition changes during a transaction.
133pub trait CatalogTrackIdentityChangeOperations {
134	fn track_identity_created(&mut self, identity: Identity) -> Result<()>;
135
136	fn track_identity_updated(&mut self, pre: Identity, post: Identity) -> Result<()>;
137
138	fn track_identity_deleted(&mut self, identity: Identity) -> Result<()>;
139}
140
141/// Trait for tracking role definition changes during a transaction.
142pub trait CatalogTrackRoleChangeOperations {
143	fn track_role_created(&mut self, role: Role) -> Result<()>;
144
145	fn track_role_updated(&mut self, pre: Role, post: Role) -> Result<()>;
146
147	fn track_role_deleted(&mut self, role: Role) -> Result<()>;
148}
149
150/// Trait for tracking granted-role changes during a transaction.
151pub trait CatalogTrackGrantedRoleChangeOperations {
152	fn track_granted_role_created(&mut self, granted_role: GrantedRole) -> Result<()>;
153
154	fn track_granted_role_deleted(&mut self, granted_role: GrantedRole) -> Result<()>;
155}
156
157/// Trait for tracking policy definition changes during a transaction.
158pub trait CatalogTrackPolicyChangeOperations {
159	fn track_policy_created(&mut self, policy: Policy) -> Result<()>;
160
161	fn track_policy_updated(&mut self, pre: Policy, post: Policy) -> Result<()>;
162
163	fn track_policy_deleted(&mut self, policy: Policy) -> Result<()>;
164}
165
166/// Trait for tracking migration definition changes during a transaction.
167pub trait CatalogTrackMigrationChangeOperations {
168	fn track_migration_created(&mut self, migration: Migration) -> Result<()>;
169
170	fn track_migration_deleted(&mut self, migration: Migration) -> Result<()>;
171}
172
173/// Trait for tracking migration event changes during a transaction.
174pub trait CatalogTrackMigrationEventChangeOperations {
175	fn track_migration_event_created(&mut self, event: MigrationEvent) -> Result<()>;
176}
177
178/// Trait for tracking authentication definition changes during a transaction.
179pub trait CatalogTrackAuthenticationChangeOperations {
180	fn track_authentication_created(&mut self, auth: Authentication) -> Result<()>;
181
182	fn track_authentication_deleted(&mut self, auth: Authentication) -> Result<()>;
183}
184
185/// Trait for tracking source definition changes during a transaction.
186pub trait CatalogTrackSourceChangeOperations {
187	fn track_source_created(&mut self, source: Source) -> Result<()>;
188
189	fn track_source_deleted(&mut self, source: Source) -> Result<()>;
190}
191
192/// Trait for tracking binding definition changes during a transaction.
193pub trait CatalogTrackBindingChangeOperations {
194	fn track_binding_created(&mut self, binding: Binding) -> Result<()>;
195
196	fn track_binding_deleted(&mut self, binding: Binding) -> Result<()>;
197}
198
199/// Trait for tracking sink definition changes during a transaction.
200pub trait CatalogTrackSinkChangeOperations {
201	fn track_sink_created(&mut self, sink: Sink) -> Result<()>;
202
203	fn track_sink_deleted(&mut self, sink: Sink) -> Result<()>;
204}
205
206/// Trait for tracking row TTL changes during a transaction.
207pub trait CatalogTrackRowTtlChangeOperations {
208	fn track_row_ttl_created(&mut self, shape: ShapeId, ttl: RowTtl) -> Result<()>;
209
210	fn track_row_ttl_updated(&mut self, shape: ShapeId, pre: RowTtl, post: RowTtl) -> Result<()>;
211
212	fn track_row_ttl_deleted(&mut self, shape: ShapeId, ttl: RowTtl) -> Result<()>;
213}
214
215/// Umbrella trait for all catalog change tracking operations.
216pub trait CatalogTrackChangeOperations:
217	CatalogTrackBindingChangeOperations
218	+ CatalogTrackDictionaryChangeOperations
219	+ CatalogTrackFlowChangeOperations
220	+ CatalogTrackHandlerChangeOperations
221	+ CatalogTrackMigrationChangeOperations
222	+ CatalogTrackMigrationEventChangeOperations
223	+ CatalogTrackNamespaceChangeOperations
224	+ CatalogTrackProcedureChangeOperations
225	+ CatalogTrackRingBufferChangeOperations
226	+ CatalogTrackRoleChangeOperations
227	+ CatalogTrackPolicyChangeOperations
228	+ CatalogTrackSeriesChangeOperations
229	+ CatalogTrackSinkChangeOperations
230	+ CatalogTrackSourceChangeOperations
231	+ CatalogTrackSumTypeChangeOperations
232	+ CatalogTrackTableChangeOperations
233	+ CatalogTrackTestChangeOperations
234	+ CatalogTrackAuthenticationChangeOperations
235	+ CatalogTrackIdentityChangeOperations
236	+ CatalogTrackGrantedRoleChangeOperations
237	+ CatalogTrackViewChangeOperations
238	+ CatalogTrackConfigChangeOperations
239	+ CatalogTrackRowTtlChangeOperations
240{
241}