-
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
Delete after insert #174
base: master
Are you sure you want to change the base?
Delete after insert #174
Conversation
0ec1b31
to
a7e30b3
Compare
7b6d8fc
to
87e711c
Compare
/** | ||
* Persists and immediately deletes some event log entries. | ||
* This is meant to be used together with infrastructure listening to a logical DB replication stream. | ||
* <p><b>Implementer's note:</b> The default implementation just calls {@link #persist(Collection)} | ||
* and {@link #delete(Collection)} and will only work if {@code persist} stores back the IDs into the objects | ||
* (which is not part of the contract). If that's not the case, this methods needs to be overridden to | ||
* implement it in a different way. | ||
* </p> | ||
* (The implementation in Nakadi-Producer Spring Boot starter reimplements this method.) | ||
* @param eventLogs the event log entries to be persisted and deleted. | ||
*/ | ||
default void persistAndDelete(Collection<EventLog> eventLogs) { | ||
persist(eventLogs); | ||
delete(eventLogs); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added this default implementation so we can stay compatible with applications which don't use the spring boot starter, but implement this manually. But it doesn't actually work, unless the persist method is implemented in a way that it fills the id field. So I wonder whether we should just skip the default implementation here?
Alternatively, we could have it throw an exception.
This is only relevant in the case that someone doesn't use the spring-boot-starter, but uses their own repository implementation. I know of exactly one app which did this (because it didn't use spring-boot), and that was decommissioned two years ago (and only ever got to version 4.3.0). Not sure we even need to worry about this.
26fe4a3
to
41affd2
Compare
- auto configuration - test for non-existence of certain beans - documentation
We create a new method for this instead of changing the existing one, as this is significantly slower this way, so it should only be used when needed.
b057e3e
to
f750c20
Compare
(This includes the changes from #171, #173, #176, #175 and builds on top. These should likely be merged first, then this one gets smaller. Implements parts of #170.)
This introduces an optional "delete-after-insert" mode. In this mode, events stored into the database will be immediately deleted.
The purpose of this is to connect the eventlog table to Fabric Event Stream's Debezium-connector (this is a Zalando-internal project), which will read the events from the logical replication log and takes care of sending them out to Nakadi.
Relevant changes:
EventLogRepositoryImpl.persistWithIds()
methods will now update theid
field in the EventLog objects (implemented using the QueryStatementBatcher from ↑).EventLogRepository.persistAndDelete()
, which, as the name implies, calls persist() and then delete(). In EventLogRepositoryImpl, it instead calls persistWithIds, so it actually works.nakadi-producer.delete-after-write
for the spring configuration which, when true, will make EventLogWriter usepersistAndDelete()
instead ofpersist()
.TODO: