Skip to content

Commit

Permalink
Rename aggregate root to aggregate
Browse files Browse the repository at this point in the history
  • Loading branch information
slashdotdash committed Nov 7, 2017
1 parent 9662ce0 commit 04e83dc
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Expand Up @@ -108,7 +108,7 @@ Using Greg's [Event Store](https://eventstore.org/):

### Enhancements

- Simplify aggregate roots and process managers ([#31](https://github.com/commanded/commanded/issues/31)).
- Simplify aggregates and process managers ([#31](https://github.com/commanded/commanded/issues/31)).

## v0.7.1

Expand Down Expand Up @@ -186,4 +186,4 @@ Using Greg's [Event Store](https://eventstore.org/):

### Enhancements

- Support integer, atom or strings as an aggregate root UUID ([#7](https://github.com/commanded/commanded/pull/7)).
- Support integer, atom or strings as an aggregate UUID ([#7](https://github.com/commanded/commanded/pull/7)).
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -5,7 +5,7 @@ Use Commanded to build your own Elixir applications following the [CQRS/ES](http
Provides support for:

- Command registration and dispatch.
- Hosting and delegation to aggregate roots.
- Hosting and delegation to aggregates.
- Event handling.
- Long running process managers.

Expand Down Expand Up @@ -36,9 +36,9 @@ MIT License
- [PostgreSQL-based EventStore](guides/Choosing%20an%20Event%20Store.md#postgresql-based-elixir-eventstore)
- [Greg Young's Event Store](guides/Choosing%20an%20Event%20Store.md#greg-youngs-event-store)
- [Using Commanded](guides/Usage.md)
- [Aggregate roots](guides/Aggregate%20Roots.md)
- [Example aggregate root](guides/Aggregate%20Roots.md#example-aggregate-root)
- [`Commanded.Aggregate.Multi`](guides/Aggregate%20Roots.md#using-commandedaggregatemulti-to-return-multiple-events)
- [Aggregates](guides/Aggregates.md)
- [Example aggregate](guides/Aggregates.md#example-aggregate)
- [`Commanded.Aggregate.Multi`](guides/Aggregates.md#using-commandedaggregatemulti-to-return-multiple-events)
- [Commands](guides/Commands.md)
- [Command handlers](guides/Commands.md#command-handlers)
- [Command dispatch and routing](guides/Commands.md#command-dispatch-and-routing)
Expand Down
14 changes: 7 additions & 7 deletions guides/Aggregate Roots.md → guides/Aggregates.md
@@ -1,24 +1,24 @@
# Aggregate roots
# Aggregates

Build your aggregate roots using standard Elixir modules and functions, with structs to hold state. There is no external dependency requirement.
Build your aggregates using standard Elixir modules and functions, with structs to hold state. There is no external dependency requirement.

An aggregate root is comprised of its state, public command functions, and state mutators.
An aggregate is comprised of its state, public command functions, and state mutators.

## Command functions

A command function receives the aggregate root's state and the command to execute. It must return the resultant domain events. This may be none, one, or multiple events.
A command function receives the aggregate's state and the command to execute. It must return the resultant domain events. This may be none, one, or multiple events.

For business rule violations and errors you may return an `{:error, reason}` tagged tuple or raise an exception.

## State mutators

The state of an aggregate root can only be mutated by applying a raised domain event to its state. This is achieved by an `apply/2` function that receives the state and the domain event. It returns the modified state.
The state of an aggregate can only be mutated by applying a raised domain event to its state. This is achieved by an `apply/2` function that receives the state and the domain event. It returns the modified state.

Pattern matching is used to invoke the respective `apply/2` function for an event. These functions *must never fail* as they are used when rebuilding the aggregate state from its history of raised domain events. You cannot reject the event once it has occurred.

## Example aggregate root
## Example aggregate

You can write your aggregate root with public API functions using the language of your domain.
You can write your aggregate with public API functions using the language of your domain.

In this bank account example, the public function to open a new account is `open_account/3`:

Expand Down
10 changes: 5 additions & 5 deletions guides/Commands.md
Expand Up @@ -27,7 +27,7 @@ defmodule BankRouter do
end
```

This can be more succinctly configured by excluding command handlers and [dispatching directly to the aggregate root](#dispatch-directly-to-aggregate), using [multi-command registration](#multi-command-registration), and with the [`identify`](#define-aggregate-identity) helper macro:
This can be more succinctly configured by excluding command handlers and [dispatching directly to the aggregate](#dispatch-directly-to-aggregate), using [multi-command registration](#multi-command-registration), and with the [`identify`](#define-aggregate-identity) helper macro:

```elixir
defmodule BankRouter do
Expand All @@ -40,9 +40,9 @@ end

## Command handlers

A command handler receives the aggregate root and the command being executed. It allows you to validate, authorize, and/or enrich the command with additional data before executing the appropriate aggregate root module function.
A command handler receives the aggregate and the command being executed. It allows you to validate, authorize, and/or enrich the command with additional data before executing the appropriate aggregate module function.

The command handler must implement the `Commanded.Commands.Handler` behaviour consisting of a single `handle/2` function. It receives the aggregate root state and the command to be handled. It must return the raised domain events from the aggregate root. It may return an `{:error, reason}` tuple on failure.
The command handler must implement the `Commanded.Commands.Handler` behaviour consisting of a single `handle/2` function. It receives the aggregate state and the command to be handled. It must return the raised domain events from the aggregate. It may return an `{:error, reason}` tuple on failure.

```elixir
defmodule OpenAccountHandler do
Expand All @@ -59,7 +59,7 @@ Command handlers execute in the context of the dispatch call, as such they are l

### Dispatch directly to aggregate

It is also possible to route a command directly to an aggregate root, without requiring an intermediate command handler.
It is also possible to route a command directly to an aggregate, without requiring an intermediate command handler.

```elixir
defmodule BankRouter do
Expand All @@ -69,7 +69,7 @@ defmodule BankRouter do
end
```

The aggregate root must implement an `execute/2` function that receives the aggregate's state and the command to execute.
The aggregate must implement an `execute/2` function that receives the aggregate's state and the command to execute.

### Dispatching commands

Expand Down
2 changes: 1 addition & 1 deletion guides/Process Managers.md
@@ -1,6 +1,6 @@
# Process managers

A process manager is responsible for coordinating one or more aggregate roots. It handles events and dispatches commands in response. Process managers have state that can be used to track which aggregate roots are being orchestrated.
A process manager is responsible for coordinating one or more aggregates. It handles events and dispatches commands in response. Process managers have state that can be used to track which aggregates are being orchestrated.

Use the `Commanded.ProcessManagers.ProcessManager` macro in your process manager module and implement the callback functions defined in the behaviour: `interested?/1`, `handle/2`, `apply/2`, and `error/4`.

Expand Down
4 changes: 2 additions & 2 deletions guides/Usage.md
Expand Up @@ -4,7 +4,7 @@ Commanded provides the building blocks for you to create your own Elixir applica

A separate guide is provided for each of the components you can build:

- Aggregate roots.
- Aggregates.
- Commands, registration and dispatch.
- Events and handlers.
- Process managers.
Expand All @@ -31,7 +31,7 @@ Here's an example bank account opening feature built using Commanded to demonstr
end
```

3. Build a `BankAccount` aggregate root to handle the command, protect its business invariants, and return a domain event when successfully handled:
3. Build a `BankAccount` aggregate to handle the command, protect its business invariants, and return a domain event when successfully handled:

```elixir
defmodule BankAccount do
Expand Down
2 changes: 1 addition & 1 deletion lib/commanded.ex
Expand Up @@ -5,7 +5,7 @@ defmodule Commanded do
Provides support for:
- [Command registration and dispatch](commands.html).
- [Hosting and delegation to aggregate roots](aggregate-roots.html).
- [Hosting and delegation to aggregates](aggregates.html).
- [Event handling](events.html).
- [Long running process managers](process-managers.html).
Expand Down
2 changes: 1 addition & 1 deletion lib/commanded/aggregates/aggregate.ex
@@ -1,7 +1,7 @@
defmodule Commanded.Aggregates.Aggregate do
@moduledoc """
Aggregate is a `GenServer` process used to provide access to an
instance of an event sourced aggregate root. It allows execution of commands
instance of an event sourced aggregate. It allows execution of commands
against an aggregate instance, and handles persistence of created events to
the configured event store.
Expand Down
2 changes: 1 addition & 1 deletion lib/commanded/commands/dispatcher.ex
Expand Up @@ -31,7 +31,7 @@ defmodule Commanded.Commands.Dispatcher do
end

@doc """
Dispatch the given command to the handler module for the aggregate root as identified
Dispatch the given command to the handler module for the aggregate as identified
Returns `:ok` on success, or `{:error, reason}` on failure.
"""
Expand Down
6 changes: 3 additions & 3 deletions lib/commanded/commands/handler.ex
Expand Up @@ -4,8 +4,8 @@ defmodule Commanded.Commands.Handler do
## Example
An open account handler that delegates to a bank account aggregate root:
An open account handler that delegates to a bank account aggregate:
defmodule OpenAccountHandler do
@behaviour Commanded.Commands.Handler
Expand All @@ -22,7 +22,7 @@ defmodule Commanded.Commands.Handler do
@type reason :: term()

@doc """
Apply the given command to the event sourced aggregate root.
Apply the given command to the event sourced aggregate.
You must return a list containing the pending events, or `nil` / `[]` when no events produced.
Expand Down
8 changes: 4 additions & 4 deletions lib/commanded/commands/router.ex
Expand Up @@ -22,9 +22,9 @@ defmodule Commanded.Commands.Router do
the aggregate's state and the command to execute. It should delegate the
command to the aggregate.
## Dispatch command directly to an aggregate root
## Dispatch command directly to an aggregate
You can route a command directly to an aggregate root, without requiring an
You can route a command directly to an aggregate, without requiring an
intermediate command handler.
### Example
Expand All @@ -35,7 +35,7 @@ defmodule Commanded.Commands.Router do
dispatch OpenAccount, to: BankAccount, identity: :account_number
end
The aggregate root must implement an `execute/2` function that receives the
The aggregate must implement an `execute/2` function that receives the
aggregate's state and the command being executed.
## Define aggregate identity
Expand Down Expand Up @@ -175,7 +175,7 @@ defmodule Commanded.Commands.Router do

@doc """
Configure the command, or list of commands, to be dispatched to the
corresponding handler for a given aggregate root
corresponding handler for a given aggregate.
"""
defmacro dispatch(command_module_or_modules, opts) do
opts = parse_opts(opts, [])
Expand Down
4 changes: 2 additions & 2 deletions lib/commanded/process_managers/process_manager.ex
Expand Up @@ -2,9 +2,9 @@ defmodule Commanded.ProcessManagers.ProcessManager do
@moduledoc """
Behaviour to define a process manager.
A process manager is responsible for coordinating one or more aggregate roots.
A process manager is responsible for coordinating one or more aggregates.
It handles events and dispatches commands in response. Process managers have
state that can be used to track which aggregate roots are being orchestrated.
state that can be used to track which aggregates are being orchestrated.
Use the `Commanded.ProcessManagers.ProcessManager` macro in your process
manager module and implement the callback functions defined in the behaviour:
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Expand Up @@ -58,7 +58,7 @@ Use Commanded to build your own Elixir applications following the CQRS/ES patter
"guides/Getting Started.md",
"guides/Choosing an Event Store.md",
"guides/Usage.md",
"guides/Aggregate Roots.md",
"guides/Aggregates.md",
"guides/Commands.md",
"guides/Events.md",
"guides/Process Managers.md",
Expand Down

0 comments on commit 04e83dc

Please sign in to comment.