Skip to main content

ddd_toolkit_core/cqrs/
mod.rs

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