-
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
#140 Persist multiple events in batch #141
#140 Persist multiple events in batch #141
Conversation
nakadi-producer/src/main/java/org/zalando/nakadiproducer/eventlog/impl/EventLogRepository.java
Outdated
Show resolved
Hide resolved
nakadi-producer/src/main/java/org/zalando/nakadiproducer/eventlog/EventLogWriter.java
Show resolved
Hide resolved
Please also extend the README in the section Creating events. |
...oot-starter/src/test/java/org/zalando/nakadiproducer/eventlog/impl/EventLogRepositoryIT.java
Show resolved
Hide resolved
* @param dataTypeToData | ||
* the content of the {@code data_type} field of the Nakadi | ||
* event mapped to some POJOs that can be serialized into JSON (required | ||
* parameter). This is meant to be a representation of the | ||
* current state of the resource. It will be used as content of | ||
* the {@code data} field of the Nakadi event. | ||
*/ | ||
@Transactional | ||
void fireCreateEvents(String eventType, Map<String, Collection<Object>> dataTypeToData); |
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 guess I missed this on my first round (or these methods were not yet there?).
Is there a reason we pass a map here instead of just one data type and a collection of DTOs?
For all data event types I know, the data_type
attribute is effectively constant (and/or ignored).
Do you have examples where regularly different values of data_type
are sent on the same event type?
If not, I would go for the simpler signature:
* @param dataTypeToData | |
* the content of the {@code data_type} field of the Nakadi | |
* event mapped to some POJOs that can be serialized into JSON (required | |
* parameter). This is meant to be a representation of the | |
* current state of the resource. It will be used as content of | |
* the {@code data} field of the Nakadi event. | |
*/ | |
@Transactional | |
void fireCreateEvents(String eventType, Map<String, Collection<Object>> dataTypeToData); | |
* @param dataType | |
* the content of the {@code data_type} field of the Nakadi | |
* event | |
* @param data | |
* some POJOs that can be serialized into JSON (required | |
* parameter). This is meant to be a representation of the | |
* current state of the resource. It will be used as content of | |
* the {@code data} field of the Nakadi event. | |
*/ | |
@Transactional | |
void fireCreateEvents(String eventType, String dataType, Collection<Object> data); |
(And analogously for the other methods.)
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.
Could you do the same change for the other fire
methods, and also the example in the README?
This comment was marked as resolved.
This comment was marked as resolved.
…com:fbrns/nakadi-producer-spring-boot-starter into issues/140-persist-multiple-events-in-batch
Co-authored-by: Paŭlo Ebermann <[email protected]>
…com:fbrns/nakadi-producer-spring-boot-starter into issues/140-persist-multiple-events-in-batch
@Mock | ||
private EventLogRepository eventLogRepository; | ||
@Mock | ||
private EventLogRepository eventLogRepository; |
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.
In this class the indentation was changed from 4 to 2. Could you please undo this? It makes seeing the actual change quite difficult.
Similarly, in some other files the indentation for new vs. old code doesn't match.
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.
Except from this, it looks good. 👍
nakadi-producer/src/main/java/org/zalando/nakadiproducer/eventlog/impl/EventLogRepository.java
Show resolved
Hide resolved
This makes it easy to pass any existing collection of a specific type to it, without an unsafe cast or an additional mapping.
* the {@code data} field of the Nakadi event. | ||
*/ | ||
@Transactional | ||
void fireCreateEvents(String eventType, String dataType, Collection<?> data); |
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.
@fbrns I've just changed the type of data
to Collection<?>
from Collection<Object>
(for all the plural fire methods).
This makes it easier to put e.g. a List<DomainObject>
into it, without having to unpack and repack it first, or do an unsafe cast (and as we don't actually write anything into this collection here, it's not needed to have a concrete type).
(I actually wanted to create a PR to your branch, but accidentally pushed directly to your branch.)
👍 |
1 similar comment
👍 |
#140 Persist multiple events in batch
Sketch for the Release notes:
fire*Events
methods to store them all in one go into the database, instead of one-by-one. This increases throughput.