nandorKollar commented on code in PR #4064:
URL: https://github.com/apache/polaris/pull/4064#discussion_r3071619992
##########
runtime/service/src/main/java/org/apache/polaris/service/events/PolarisEventListeners.java:
##########
@@ -31,23 +31,68 @@
import jakarta.enterprise.inject.Any;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;
+import java.util.BitSet;
+import java.util.EnumSet;
import java.util.HashSet;
-import java.util.Set;
import org.apache.polaris.service.events.listeners.PolarisEventListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@ApplicationScoped
public class PolarisEventListeners {
+ private static final Logger LOGGER =
LoggerFactory.getLogger(PolarisEventListeners.class);
+
@Inject EventBus eventBus;
@Inject @Any Instance<PolarisEventListener> eventListeners;
@Inject PolarisEventListenerConfiguration configuration;
+ private final BitSet eventsByType = new
BitSet(PolarisEventType.values().length);
+
public void onStartup(@Observes StartupEvent event) {
- Set<String> listenerTypeSet =
configuration.types().orElseGet(HashSet::new);
+ var listenerTypeSet = configuration.types().orElseGet(HashSet::new);
for (String enabledEventListener : listenerTypeSet) {
- PolarisEventListener listener =
-
eventListeners.select(Identifier.Literal.of(enabledEventListener)).get();
- Handler<Message<PolarisEvent>> handler = e -> listener.onEvent(e.body());
- eventBus.localConsumer(POLARIS_EVENT_CHANNEL, handler);
+ var listenerConfiguration =
configuration.listenerConfig().get(enabledEventListener);
+ var supportedTypes =
+ listenerConfiguration == null
Review Comment:
Despite this doesn't seem to be a problem now, it is reasonable to expect
that when someone extends `ListenerConfiguration`, then there should be no need
to list every event type. How about this:
```
var supportedTypes =
listenerConfiguration == null ||
(listenerConfiguration.enabledEventCategories().isEmpty() &&
listenerConfiguration.enabledEventTypes().isEmpty())
? EnumSet.allOf(PolarisEventType.class)
: EnumSet.noneOf(PolarisEventType.class);
```
This should make it future-proof though I don't think we can cover this with
a test case, as `ListenerConfiguration` has only these two configs now.
--
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]