Comments (1)
Yes, this feature is a useful suggestion.
Right now in Commanded, the command-to-aggregate identity mapping is handled by your router module. You specify the identity
option for each command:
defmodule BankRouter do
use Commanded.Commands.Router
dispatch OpenAccount, to: BankAccount, identity: :account_number
end
Therefore we could use this as the extension point.
Router identity prefix
-
Include another option to specify the identity prefix:
defmodule BankRouter do use Commanded.Commands.Router dispatch [OpenAccount,DepositMoney,WithdrawMoney] to: BankAccount, identity: :account_number, identity_prefix: "bank-account-" end
-
Allow a function to be used as the
identity
option, it could then construct the identity as required from the command being dispatched:defmodule BankRouter do use Commanded.Commands.Router dispatch [RegisterUser] to: User, identity: fn %{uuid: uuid} -> "user-#{uuid}" end dispatch [OpenAccount,DepositMoney,WithdrawMoney] to: BankAccount, identity: &BankRouter.account_identity/1 def account_identity(%{account_number: account_number}), do: "bank-account-#{account_number}" end
-
Allow an aggregate identity to be specified for all its commands, providing an optional prefix:
defmodule BankRouter do use Commanded.Commands.Router identify BankAccount, by: :account_number, prefix: "bank-account-" dispatch [OpenAccount,DepositMoney,WithdrawMoney] to: BankAccount end
from commanded.
Related Issues (20)
- 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
- EventstoreDB is sunsetting the TCP protocol HOT 1
- Is it a bad practice for an event handler to depend on a projector completion? HOT 2
- Snapshotting 2 Aggregates having same identity
- Is it possible to log contents of InMemoryEventStore on failed test?
- Ecto Sandbox, Projections and In Memory adapter HOT 3
- Aggregate throws error when execute returns more than 1000 events.
- Individual stream events handling HOT 2
- Skipped event with concurrency enabled HOT 9
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.