dimas-b commented on code in PR #4648:
URL: https://github.com/apache/polaris/pull/4648#discussion_r3405369855
##########
runtime/service/src/main/java/org/apache/polaris/service/events/PolarisEventListeners.java:
##########
@@ -136,4 +166,58 @@ private void deliverEvent(
public boolean hasListeners(PolarisEventType eventType) {
return eventTypesWithListeners.contains(eventType);
}
+
+ private static class ListenerExecutor implements Executor {
+
+ private final Executor delegate;
+ private final Queue<Runnable> queue;
+ private final AtomicBoolean draining = new AtomicBoolean(false);
+
+ ListenerExecutor(Executor delegate, int capacity) {
+ this.delegate = delegate;
+ this.queue =
+ capacity == -1 ? new ConcurrentLinkedQueue<>() : new
ArrayBlockingQueue<>(capacity);
+ }
+
+ @Override
+ @SuppressWarnings("FutureReturnValueIgnored")
+ public void execute(@NonNull Runnable task) {
+ if (!queue.offer(task)) {
+ throw new RejectedExecutionException("Event listener queue is full");
+ }
+ maybeScheduleDrain();
Review Comment:
Should we do `.exceptionally(this::onError)` here too? Line 200 may return a
failed `CompletableFuture` without logging its exception, I guess 🤔
In this case, we probably do not have to reset `draining` on line 199, WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]