Package kos.api
Class EventBusSink.Result
java.lang.Object
kos.api.EventBusSink.Result
- Enclosing interface:
- EventBusSink
Represents the outcome of an attempt to initialise either
EventSubscriptionSink
or EventPublisherSink.
Developers are encouraged to not throw exceptions when initialising
Sinks. As a last-resort, one might store exceptions in failureCause.
If the Sink is not entitled to initialise a given address, one
can just return NOT_ATTEMPTED.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) boolean(package private) ThrowableHolds the cause of a possible failure.(package private) booleanTells whether the Sink was initialised or not.static final EventBusSink.ResultIdentifies that a given sink haven't tried to be initialised.(package private) StringThe local address which Kos will use to bridge the communication between Producers and Consumers. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic EventBusSink.ResultGenerates a result indicating a failure.getRewrittenAddressOr(String defaultValue) static EventBusSink.ResultsucceededAtAddress(String rewrittenAddress) Returns a Result object indicating that the Sink managed to start the communication with the remote broker.static EventBusSink.ResultsucceededAtAddress(String rewrittenAddress, Boolean eventuallyConsistent) Returns a Result object indicating that the Sink managed to start the communication with the remote broker.
-
Field Details
-
initialised
boolean initialisedTells whether the Sink was initialised or not. -
failureCause
Throwable failureCauseHolds the cause of a possible failure. It is null in case the initialisation succeeds. -
rewrittenAddress
String rewrittenAddressThe local address which Kos will use to bridge the communication between Producers and Consumers. -
eventuallyConsistent
boolean eventuallyConsistent -
NOT_ATTEMPTED
Identifies that a given sink haven't tried to be initialised. Sink developers are encouraged to returnResult.NOT_ATTEMPTEDwhenever the Sink cannot handle the informedaddress.
-
-
Constructor Details
-
Result
public Result()
-
-
Method Details
-
getRewrittenAddressOr
-
failure
Generates a result indicating a failure. Failure results are terminal and might immediately stop the application. -
succeededAtAddress
Returns a Result object indicating that the Sink managed to start the communication with the remote broker. As a result, all communication made through EventBus on the informedrewrittenAddresswill be bridged by the remote broker. The communication semantics will always be consistent, yielding a failure Future object whenever the communication with the remote broker fails - succeeding otherwise. This model does not allow one channel to have more than one consumer. However, given that this method was designed to bridge the communication with a remote broker, rather than providing broadcast semantics locally, this implications might actually be the desirable behaviour. -
succeededAtAddress
public static EventBusSink.Result succeededAtAddress(String rewrittenAddress, Boolean eventuallyConsistent) Returns a Result object indicating that the Sink managed to start the communication with the remote broker. As a result, all communication made through EventBus on the informedrewrittenAddresswill be bridged by the remote broker.- Parameters:
eventuallyConsistent- if set to true, it will implement a fire-and-forget semantic, succeeding the operation whenever the message reaches the EventBus. If set to false it will behave exactly likesucceededAtAddress(String, Boolean).
-