ddd_toolkit_core/cqrs/mod.rs
1//! **English:**<br>
2//! CQRS handlers and lifecycle coordination for aggregate commands and queries.
3//!
4//! Lifecycle contexts require a successful save and event dispatch before completion.
5//! A failed attempt is consumed and cannot be retried through the same context.
6//!
7//! **日本語:**<br>
8//! 集約に対するコマンド・クエリの CQRS ハンドラーとライフサイクル調整機能を提供します。
9//!
10//! ライフサイクルコンテキストは完了前に保存とイベント配信の成功を要求します。
11//! 失敗した操作は消費済みとなり、同じコンテキストから再試行できません。
12
13mod async_query_handler;
14mod query_handler;
15
16pub use async_query_handler::*;
17
18pub use query_handler::*;
19
20#[derive(Debug, Clone, Copy, PartialEq, Eq)]
21/// **English:**<br>
22/// Records whether a lifecycle operation is pending, successful, or consumed by failure.
23///
24/// **日本語:**<br>
25/// ライフサイクル操作が未実行、成功、または失敗により消費済みかを表します。
26pub enum OperationState {
27 /// **English:**<br>
28 /// The operation has not been attempted.
29 ///
30 /// **日本語:**<br>
31 /// 操作はまだ試行されていません。
32 Pending,
33 /// **English:**<br>
34 /// The operation completed successfully.
35 ///
36 /// **日本語:**<br>
37 /// 操作は正常に完了しました。
38 Succeeded,
39 /// **English:**<br>
40 /// The operation failed or its future was dropped after starting; retry is disallowed.
41 ///
42 /// **日本語:**<br>
43 /// 操作が失敗したか開始後に future が破棄され、再試行できません。
44 FailedConsumed,
45}
46
47#[derive(Debug, PartialEq, Eq)]
48/// **English:**<br>
49/// An error returned when a lifecycle save or dispatch cannot be attempted or its adapter fails.
50///
51/// **日本語:**<br>
52/// ライフサイクルの保存・配信を実行できない場合、またはアダプターが失敗した場合のエラーです。
53pub enum LifecycleOperationError<E> {
54 /// **English:**<br>
55 /// The repository or publisher returned this adapter error.
56 ///
57 /// **日本語:**<br>
58 /// リポジトリまたはパブリッシャーが返したアダプターエラーです。
59 Adapter(E),
60 /// **English:**<br>
61 /// Save was already attempted on this context.
62 ///
63 /// **日本語:**<br>
64 /// このコンテキストでは保存がすでに試行されています。
65 AlreadySaved,
66 /// **English:**<br>
67 /// Dispatch was already attempted on this context.
68 ///
69 /// **日本語:**<br>
70 /// このコンテキストでは配信がすでに試行されています。
71 AlreadyDispatched,
72}
73
74#[derive(Debug, Clone, Copy, PartialEq, Eq)]
75/// **English:**<br>
76/// Describes why a lifecycle context cannot be completed.
77///
78/// **日本語:**<br>
79/// ライフサイクルコンテキストを完了できない理由を示します。
80pub enum LifecycleCompletionError {
81 /// **English:**<br>
82 /// No save was attempted before completion.
83 ///
84 /// **日本語:**<br>
85 /// 完了前に保存が試行されていません。
86 MissingSave,
87 /// **English:**<br>
88 /// No event dispatch was attempted before completion.
89 ///
90 /// **日本語:**<br>
91 /// 完了前にイベント配信が試行されていません。
92 MissingDispatch,
93 /// **English:**<br>
94 /// The save attempt failed and was consumed.
95 ///
96 /// **日本語:**<br>
97 /// 保存の試行が失敗し、消費済みです。
98 SaveFailedConsumed,
99 /// **English:**<br>
100 /// The dispatch attempt failed and was consumed.
101 ///
102 /// **日本語:**<br>
103 /// 配信の試行が失敗し、消費済みです。
104 DispatchFailedConsumed,
105}