Comments (7)
How will this translate to non-execute version? Or will it just stay the same (which is ok I think)?
from commanded.
@drozzy Good catch, I think that also needs to change, proposal as below.
Current: Command handler receives default %BankAccount{}
state
defmodule OpenAccountHandler do
@behaviour Commanded.Commands.Handler
def handle(%BankAccount{} = aggregate, %OpenAccount{account_number: account_number, initial_balance: initial_balance}) do
BankAccount.open_account(aggregate, account_number, initial_balance)
end
end
Proposal: Command handler receives no state
When there are no persisted events for the aggregate.
defmodule OpenAccountHandler do
@behaviour Commanded.Commands.Handler
def handle(%OpenAccount{account_number: account_number, initial_balance: initial_balance}) do
BankAccount.open_account(account_number, initial_balance)
end
end
from commanded.
Wouldn't that need to percolate down to the apply
function?
It presently takes a state. Unless you do:
def apply(%AccountOpened{..}) do
%InitialStateHere{}
end
from commanded.
@drozzy I'm undecided about changing the apply/2
function.
from commanded.
Is there any update on this issue?
Still undecided? Abandoned ?
from commanded.
I would prefer not using a apply but a create function, since the aggregate does not exists if it is not created.
It does makes more sense to say that a command was processed and created and event and and aggregate, that say that the aggregate already existed with nil fields
It would also help with pattern matching on execute(), if there's no aggregate it should return nil on the execute function and the default call should return {:error, :aggregate_not_created}
from commanded.
Prefer something like new
or initial_state
; otherwise, it would be confusing. Also, some folks are aligned around https://thinkbeforecoding.com/post/2021/12/17/functional-event-sourcing-decider in terms of naming things to some extent.
Being said, since structs allow you to have default values, I am wondering if this should be a feature.
from commanded.
Related Issues (20)
- how to migrate or modify events HOT 2
- Update sponsors in BACKERS and README HOT 1
- General design philosophy question: sending email from process manager HOT 4
- update FAQ regarding scheduling HOT 1
- Wiki Testing section is outdated HOT 1
- warning: redefining module Commanded.Serialization.JsonDecoder.Any HOT 2
- Event number gaplessness required?
- Commanded.aggregate_state does not work when aggregate identity has a prefix HOT 10
- Process manager router option not working
- Lessons learned from performance optimization - an unlikely culprit HOT 3
- no function clause matching in Commanded.Commands.Dispatcher.telemetry_stop/3 HOT 1
- Docs questions
- Stacktrace in event handler error? HOT 2
- Paralelization Strategies in EventHandlers
- Should Commanded.Event.Handler support messages from swarm? HOT 2
- Event retention policies?
- please support multiple commanded application with one eventstore HOT 6
- Process Manager state serialization breaks when using a custom TypeProvider with the JsonSerializer
- `Commanded.ProcessManagers.ProcessManager.identity/0` function returns `nil` in unit tests
- no function clause matching in Commanded.Event.Handler.partition_event/4 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from commanded.