Skip to content

Commit

Permalink
#48 add some javadocs to internal methods for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
ePaul committed Feb 6, 2019
1 parent ae5a2a2 commit 9c56ac5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public EventBatcher(ObjectMapper objectMapper, Consumer<List<BatchItem>> publish
this.aggregatedBatchSize = 0;
}

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

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

/**
* Publishes all events which were pushed and not yet published.
*/
public void finish() {
if (!batch.isEmpty()) {
this.publisher.accept(batch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public void sendEvents(Collection<EventLog> events) {
batcher.finish();
}

/**
* Publishes a list of events.
* All of the events in this list need to be destined for the same event type.
*/
private void publishBatch(List<BatchItem> batch) {
try {
this.tryToPublishBatch(batch);
Expand All @@ -81,6 +85,10 @@ private void publishBatch(List<BatchItem> batch) {
}
}

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

0 comments on commit 9c56ac5

Please sign in to comment.