Skip to content
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

GH-157: expose a timeout configurable pollJournalForEvents method #161

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,28 @@ public boolean pollJournalForEvent(String journalUrl, String eventId,

/**
* Polls the journal for the given eventIds. The journal is polled until all eventIds are found.
* The timeout is set to 2 minutes.
* @param journalUrl The journal url
* @param eventIds The eventIds to find (the set is not modified)
* @param isEventIdInEvent The predicate to use to find the eventIds in the journal
* @return true if all eventIds are found, false otherwise (if timeout is reached).
*/
public boolean pollJournalForEvents(String journalUrl, Set<String> eventIds, BiPredicate<Event, String> isEventIdInEvent) {
public boolean pollJournalForEvents(String journalUrl, Set<String> eventIds,
BiPredicate<Event, String> isEventIdInEvent) {
return pollJournalForEvents(journalUrl, eventIds, isEventIdInEvent,
JOURNAL_POLLING_TIME_OUT_IN_MILLISECONDS);
}

/**
* Polls the journal for the given eventIds. The journal is polled until all eventIds are found.
* @param journalUrl The journal url
* @param eventIds The eventIds to find (the set is not modified)
* @param isEventIdInEvent The predicate to use to find the eventIds in the journal
* @param timeoutInMilliseconds The timeout in milliseconds
* @return true if all eventIds are found, false otherwise (if timeout is reached).
*/
public boolean pollJournalForEvents(String journalUrl, Set<String> eventIds,
BiPredicate<Event, String> isEventIdInEvent, long timeoutInMilliseconds) {
JournalService journalService = JournalService.builder()
.workspace(workspace)
.url(journalUrl)
Expand Down Expand Up @@ -121,7 +137,7 @@ public boolean pollJournalForEvents(String journalUrl, Set<String> eventIds, BiP
logger.error("Interrupted while sleeping", e);
}
entry = journalService.get(entry.getNextLink());
} while(pollingDuration < JOURNAL_POLLING_TIME_OUT_IN_MILLISECONDS);
} while(pollingDuration < timeoutInMilliseconds);
// We did not find all eventIds in the journal, signal it.
logger.error("We polled the journal for " + JOURNAL_POLLING_TIME_OUT_IN_MILLISECONDS
+ " milliseconds and could NOT find the expected eventIds.");
Expand Down