https://github.com/holsee/inventory_es
Macros for an Event Sourced inventory system (from CodeMesh training w/ Greg Young)
https://github.com/holsee/inventory_es
commands elixir events macros
Last synced: 2 months ago
JSON representation
Macros for an Event Sourced inventory system (from CodeMesh training w/ Greg Young)
- Host: GitHub
- URL: https://github.com/holsee/inventory_es
- Owner: holsee
- Created: 2019-11-06T17:03:52.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T00:39:06.000Z (over 2 years ago)
- Last Synced: 2025-02-13T07:36:01.386Z (4 months ago)
- Topics: commands, elixir, events, macros
- Language: Elixir
- Homepage:
- Size: 998 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Inventory ES
The only interesting aspect is the way commands and events are defined.
Examples same for commands.
```elixir
defmodule Inventory.Events do
defevent CheckoutOut,
count: integer()
end
``````
iex -S mix
```Generated type specification:
```elixir
t Inventory.Events.CheckedOut.t()@type t() :: %Inventory.Events.CheckedOut{
count: integer(),
id: Id.t(),
timestamp: Timestamp.t()
}
```Create event:
```elixir
Inventory.Events.CheckedOut.create(count: 100)%Inventory.Events.CheckedOut{
count: 100,
id: "e5d37047-3873-4bad-b123-3d422adf25c5",
timestamp: 1573060299826
}
```Key validation (not type, only dialyzer will save you):
```elixir
Inventory.Events.CheckedOut.create()
# => boom! 'count' missing
```