Use Absinthe.Subscription.publish/3 to manually publish a mutation after a Commanded Ecto projection has updated a read model in the after_update/3 callback function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule JsonSerializer do | |
| alias Commanded.EventStore.TypeProvider | |
| alias Commanded.Serialization.JsonDecoder | |
| @doc """ | |
| Serialize given term to JSON binary data. | |
| """ | |
| def serialize(term) do | |
| Jason.encode!(term) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule OpenAccount do | |
| defstruct [:account_number, :initial_balance] | |
| @types %{ | |
| account_number: :string, | |
| initial_balance: :integer | |
| } | |
| def validate(params) do | |
| {params, @types} |
Implement a default event handler error/3 callback function with optional support for retrying failed events before eventually skipping it.
defmodule MyApp.ExampleHandler do
use Commanded.Event.Handler, name: __MODULE__
use Commanded.Event.DefaultErrorHandling, retries: 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule CloudWatchReporter do | |
| use GenServer | |
| require Logger | |
| alias ExAws.Cloudwatch | |
| @namespace "My/App" | |
| def start_link(args) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Commanded.EventTelemetry do | |
| @moduledoc """ | |
| A Commanded event handler to produce `:telemetry` events for each recorded | |
| event. | |
| It produces the following event: | |
| - `[:commanded, :event, :published]` | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Commanded.Middleware.Telemetry do | |
| @moduledoc """ | |
| A Commanded middleware to instrument the command dispatch pipeline with | |
| `:telemetry` events. | |
| It produces the following three events: | |
| - `[:commanded, :command, :dispatch, :start]` | |
| - `[:commanded, :command, :dispatch, :success]` | |
| - `[:commanded, :command, :dispatch, :failure]` |
From Design It! From Programmer to Software Architect by Michael Keeling.
- Partition system and assign responsibilities.
- Decide trade-offs among quality attributes:
- Performance (response time)
- Scalability (annual growth)
- Availability
- Security
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule AggregateCase do | |
| @moduledoc """ | |
| Defines a test case to be used by aggregate tests. | |
| """ | |
| use ExUnit.CaseTemplate | |
| alias Commanded.Aggregate.Multi | |
| using opts do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule JsonbSerializer do | |
| @moduledoc """ | |
| Serialize to/from PostgreSQL's native `jsonb` format. | |
| """ | |
| @behaviour EventStore.Serializer | |
| alias Commanded.EventStore.TypeProvider | |
| alias Commanded.Serialization.JsonDecoder |