Package io.elastic.api
Class EventEmitter
java.lang.Object
io.elastic.api.EventEmitter
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Used to buildEventEmitter
instances.static interface
This interface defines a callback to pass errors, data and snapshots to its callee. -
Method Summary
Modifier and TypeMethodDescriptionEmits aMessage
.Emits anException
.emitHttpReply
(HttpReply reply) Emits the httpReply event.emitRebound
(Object reason) Emits the rebound event specifying aObject
reason.emitSnapshot
(jakarta.json.JsonObject snapshot) EmitsJsonObject
snapshot.emitUpdateKeys
(jakarta.json.JsonObject object) Emits the updateKeys event.
-
Method Details
-
emitException
Emits anException
. 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
Emits aMessage
.- Parameters:
message
- message to emit- Returns:
- this instance
-
emitSnapshot
EmitsJsonObject
snapshot.- Parameters:
snapshot
- snapshot to emit- Returns:
- this instance
-
emitRebound
Emits the rebound event specifying aObject
reason.- Parameters:
reason
- reason for rebound- Returns:
- this instance
-
emitUpdateKeys
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
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
-