-
Notifications
You must be signed in to change notification settings - Fork 42
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
Delay event uuid generation until it is requested or external generator supplied #82
Comments
interesting approach and I agree that a custom uuid generator could be useful. So I think the solution can work but we should not include it in the core. |
@codeliner I agree that it should not be used by default. It is a decision for the event implementers. However, I think following would be useful in the core:
That is if this approach is sensible at all. I can't think of a use case for event uuid in the aggregate at this time but I might be missing something. |
To clarify about immutability: in the code example I provided existence of uuid is explicitly checked and results in a noop if one is set exactly for that reason: to maintain immutability contract. Also, I think event interface would belong here, together with extractors, not in common. |
Sounds like a good plan. I need to think about it and let's see what @prolic says about it. One thing that bothers me: It feels complex or too much. Do you know what I mean? Instead of providing one solution the user has to decide now. We don't touch the default, ok. But more classes, more opportunities and maybe more confusion than necessary. Not sure, maybe I need to see it in action first. Do you want to provide a PR even without definit OK? |
Yeah, there is that. Plus uuid optimisations are usually needed way down the line, when most of the stuff is already there and working.
Probably not until august. |
The problems I see with setting the IDs so late are:
Imho, if you need a custom event ID it should be provided on event creation (so set it explicitly there by whomever creates the event). If implemented, I think this should go to the message bus instead. Still the issue remains to return the ID to the one submitting it (for correlation tracking ... ). |
I think the ID is part of the event / query / command. Therefore the ID should not be added lately by some magic that's hidden somewhere else. |
There is one case I didn't account for here: cloning event without uuid will result in different values when it is finally created on access. |
I would like to throw in an idea for improvement around event ids.
Currently, if you want to employ different uuid generation strategy, for example COMB, ramsey uuid lib has to be configured statically beforehand.
I think it would be beneficial to delay event uuid generation (currently happens in
DomainMessage::init()
) until it is requested by something, which should not occur before extractor is run in most cases.That would allow us to explicitly supply uuid generator in a clean way from infrastructure with a proper dependency injection:
The text was updated successfully, but these errors were encountered: