Class EventEmitter

java.lang.Object
io.elastic.api.EventEmitter

public final class EventEmitter extends Object
Used by a Function to communicate with the elastic.io runtime. The implementation of this class has been inspired by the Node.js EventEmitter class.
See Also:
  • Method Details

    • emitException

      public EventEmitter emitException(Exception e)
      Emits an Exception. Used to emit an exception from component written in asynchronous style, for example using Reactive Extensions for the JVM . Any non-asynchronous may throw an exception instead of using this method.
      Parameters:
      e - exception to emit
      Returns:
      this instance
    • emitData

      public EventEmitter emitData(Message message)
      Emits a Message.
      Parameters:
      message - message to emit
      Returns:
      this instance
    • emitSnapshot

      public EventEmitter emitSnapshot(jakarta.json.JsonObject snapshot)
      Emits JsonObject snapshot.
      Parameters:
      snapshot - snapshot to emit
      Returns:
      this instance
    • emitRebound

      public EventEmitter emitRebound(Object reason)
      Emits the rebound event specifying a Object reason.
      Parameters:
      reason - reason for rebound
      Returns:
      this instance
    • emitUpdateKeys

      public EventEmitter emitUpdateKeys(jakarta.json.JsonObject object)
      Emits the updateKeys event. This method is typically used in components authorizing with OAuth2 apis. If an access token is expired, the component needs to refresh them. The refreshed tokens need to be communicated to the elastic.io platform so that the component is executed with refreshed tokens next time.
      Parameters:
      object - object containing the tokens
      Returns:
      this instance
    • emitHttpReply

      public EventEmitter emitHttpReply(HttpReply reply)
      Emits the httpReply event. This method is typically used to emit a HTTP reply in real-time flows.
      Parameters:
      reply - HTTP reply
      Returns:
      this instance