コマンドハンドラーとは?
コマンドハンドラーとは、状態を変更する意図を表す単一のコマンドオブジェクトを受け取り、その変更を実行するコードの単位です。リクエストを検証し、関連する集約を読み込み、ビジネスルールを適用し、結果を永続化します。各コマンド型は通常、ちょうど1つのハンドラーに対応します。
なぜ重要か
各書き込み操作を独自のハンドラーに分離することで、ビジネスロジックを焦点の定まったテストしやすいものに保ちます。これは、書き込み側が読み取りとは別にモデル化されるCQRSの中核的な構成要素です。
関連ガイド
What Is a Query Handler?A query handler is the component that answers a read request by fetching and shaping data, without changing a…
What Is CQRS?CQRS separates the model used to change data from the model used to read it, letting writes and reads be desi…
What Is an Aggregate Root?An aggregate root is the single entity through which all access to a cluster of related domain objects flows,…