-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Additional stream prefix per aggregate #77
Comments
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 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
|
It would be useful to be able to define a prefix on a per-aggregate basis. This would reduce risk of collisions when using a lot of aggregates with generated IDs and ease separation of streams on a business logic level.
Example
Let's assume we have a general User aggregate which uses UUIDs as identification. For our business logic we need to relate additional data to this user, as such we add additional aggregates which also use the user ids as identification for ease of use. While being related but separate entities this would result in a single stream containing all events from all aggregates per user.
Proposal
Similar to process managers or event handlers the name of an aggregate could be defined in a use clause. This could internally define a
@behaviour
conformance with a callback providing the aggregate name.To allow backwards compatibility the
Aggregate
module could usefunction_exported?/3
to check for the behaviour conformance in advance and fall back to the current logic. The old behaviour could be deprecated if wished for and removed in a later version.What do you think of this?
The text was updated successfully, but these errors were encountered: