-
Notifications
You must be signed in to change notification settings - Fork 8
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
Configurable eid generation strategy. #191
Comments
Thanks for your suggestion. (I slightly reworded it, feel free to revert or edit again if I managed to misrepresent your intention.) My approach for more flexibility would be to inject an EidConverterStrategy interface which can convert the database counter (as
With the spring-boot starter, just providing such an object as a bean could be enough for the auto configuration to pick it up and inject into either the transmission service or the eventlog writer (and for the implementations we deliver with the library, we can also provide config file options to generate the bean). A small complication here is that the way we are currently storing the events, the ID is only known after storing it into the DB, so doing this generation beforehand (which would be needed if we want randomness + idempotency on resending) is difficult. (Maybe some option could be to have a two-step process, inject one before storing and one after reading from the DB.) |
If I understood correctly do you want to generate eid when called mapToNakadiEvent in the
I think the idempotency on resending is one of the most important features which should be support. For
We can use different |
At this moment we have hardcoded logic for generating new eid value - link
There are following advantages for this solution:
But also we have some disadvantages:
In some cases it topics with multiple producers are needed (or at least very nice to have), and we should have a uniqueness guarantee of eids at least per event type for them.
I see the these possible solutions:
Based on configuration, use different strategy for
convertToUUID
method: current (by default) or UUID.randomUUID().The main changes are needed in mapToNakadiEvent and tryToPublishBatch.
But in this case we lose all advantages of the current solution with randomUUID generation.
Add additional
eid
column with generated eid to event_log table.Before persisting the event, event generate
randomUUID
in createEventLog and persist theEventLog
entity with already generated eid.When we try to send event to nakadi, we can choose the different strategy based on
eid
field. If there is data there, then useeid
field, if not, thenid
with default strategy. (Again don't forget about failed events resolving in tryToPublishBatch).In this case we have guarantee for repulishing, but lose sequential eid generation logic (possibly we can use
spanCtx
and addid
field as key here).The text was updated successfully, but these errors were encountered: