Class MetricsEventBus

java.lang.Object
org.apache.dubbo.metrics.event.MetricsEventBus

public class MetricsEventBus extends Object
Dispatches events to listeners, and provides ways for listeners to register themselves.
  • Constructor Details

    • MetricsEventBus

      public MetricsEventBus()
  • Method Details

    • publish

      public static void publish(MetricsEvent event)
      Posts an event to all registered subscribers and only once.
      Parameters:
      event - event to post.
    • post

      public static <T> T post(MetricsEvent event, Supplier<T> targetSupplier)
      Posts an event to all registered subscribers. Full lifecycle post, judging success or failure by whether there is an exception Loop around the event target and return the original processing result
      Parameters:
      event - event to post.
      targetSupplier - original processing result targetSupplier
    • post

      public static <T> T post(MetricsEvent event, Supplier<T> targetSupplier, Function<T,Boolean> trFunction)
      Full lifecycle post, success and failure conditions can be customized
      Type Parameters:
      T - Biz result type
      Parameters:
      event - event to post.
      targetSupplier - original processing result supplier
      trFunction - Custom event success criteria, judged according to the returned boolean type
      Returns:
      Biz result
    • tryInvoke

      public static void tryInvoke(Runnable runnable)
    • before

      public static void before(MetricsEvent event)
      Applicable to the scene where execution and return are separated, eventSaveRunner saves the event, so that the calculation rt is introverted
    • after

      public static void after(MetricsEvent event, Object result)
    • error

      public static void error(MetricsEvent event)