Skip to content

Commit 3787db8

Browse files
committed
#48 add some javadocs to internal methods for clarity
1 parent 6b14f61 commit 3787db8

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

nakadi-producer/src/main/java/org/zalando/nakadiproducer/transmission/impl/EventBatcher.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ public EventBatcher(ObjectMapper objectMapper, Consumer<List<BatchItem>> publish
3030
this.aggregatedBatchSize = 0;
3131
}
3232

33+
/**
34+
* Pushes one event to be published. It will be either published right now, or with some other events,
35+
* latest when calling {@link #finish()}.
36+
* @param eventLogEntry The event log entry for this event.
37+
* @param nakadiEvent The Nakadi form of the event.
38+
*/
3339
public void pushEvent(EventLog eventLogEntry, NakadiEvent nakadiEvent) {
3440
long eventSize;
3541

@@ -53,6 +59,9 @@ public void pushEvent(EventLog eventLogEntry, NakadiEvent nakadiEvent) {
5359
aggregatedBatchSize += eventSize;
5460
}
5561

62+
/**
63+
* Publishes all events which were pushed and not yet published.
64+
*/
5665
public void finish() {
5766
if (!batch.isEmpty()) {
5867
this.publisher.accept(batch);

nakadi-producer/src/main/java/org/zalando/nakadiproducer/transmission/impl/EventTransmissionService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ public void sendEvents(Collection<EventLog> events) {
7373
batcher.finish();
7474
}
7575

76+
/**
77+
* Publishes a list of events.
78+
* All of the events in this list need to be destined for the same event type.
79+
*/
7680
private void publishBatch(List<BatchItem> batch) {
7781
try {
7882
this.tryToPublishBatch(batch);
@@ -81,6 +85,10 @@ private void publishBatch(List<BatchItem> batch) {
8185
}
8286
}
8387

88+
/**
89+
* Tries to publish a set of events (all of which need to belong to the same event type).
90+
* The successful ones will be deleted from the database.
91+
*/
8492
private void tryToPublishBatch(List<BatchItem> batch) throws Exception {
8593
Stream<EventLog> successfulEvents;
8694
String eventType = batch.get(0).getEventLogEntry().getEventType();

0 commit comments

Comments
 (0)