adutra commented on PR #3442:
URL: https://github.com/apache/polaris/pull/3442#issuecomment-3769231647

   > We will not be able to enumerate listeners (unless we add some additional 
mechanisms for that)
   
   The introduction of an event bus is not incompatible with the idea of only 
firing the event if there is one interested listener. My 
`PolarisEventDispatcher` above could be rewritten as follows:
   
   ```java
   @ApplicationScoped
   public class PolarisEventDispatcher {
   
     private final EventBus eventBus;
     private final EnumSet<PolarisEventType> supportedTypes;
   
     @Inject
     public PolarisEventDispatcher(EventBus eventBus, @Any 
Instance<PolarisEventListener> listeners) {
       this.eventBus = eventBus;
       this.supportedTypes = EnumSet.noneOf(PolarisEventType.class);
       for (PolarisEventListener listener : listeners) {
         this.supportedTypes.addAll(listener.supportedEventTypes());
       }
     }
   
     public boolean hasListeners(PolarisEventType type) {
       return supportedTypes.contains(type);
     }
   
     public void fireEvent(PolarisEvent event) {
       eventBus.publish(event.type().name(), event);
     }
   }
   ```
   
   > messages will be serialized, so Supplier is not an options as well.
   
   That is partially true :-) In general, as soon as a bus is involved, you are 
right to ask yourself the question of how the elements in the bus are 
serialized. 
   
   The trick here though is that this bus is local to the Polaris instance, so 
there is no serialization at all. That's why I didn't mention serialization in 
my review. (See https://quarkus.io/guides/reactive-event-bus#using-codecs for 
more).
   
   


-- 
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]

Reply via email to