Abyss-lord opened a new pull request, #6881:
URL: https://github.com/apache/gravitino/pull/6881

   ### What changes were proposed in this pull request?
   
   Refactor EventBus#dispatchEvent. 
   By adding the `accept(EventVisitor visitor)` method to BaseEvent and its 
subclasses, the handling logic is delegated to the event itself. This allows 
the EventBus to simply call `event.accept(InternalVisitor())`, with the event 
determining how it should be processed.
   
   1. **Type-safe** – Eliminates the need for `instanceof` checks
   2. **Clear decoupling** – Events are only responsible for invoking `accept` 
method, without knowing the listener implementation
   3. **Strong encapsulation** – Prevents external misuse by restricting direct 
access to visitor methods
   4. **Easily extensible** – Adding new event types only requires creating new 
classes and visitXxx() methods, without modifying the dispatch logic
   
   ### Why are the changes needed?
   
   Fix: #6880
   
   ### Does this PR introduce _any_ user-facing change?
   
   no
   
   ### How was this patch tested?
   
   local test.
   


-- 
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: commits-unsubscr...@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to