Package kos.api
Class EventBusSink.Result
- java.lang.Object
-
- kos.api.EventBusSink.Result
-
- Enclosing interface:
- EventBusSink
public static class EventBusSink.Result extends Object
Represents the outcome of an attempt to initialise eitherEventSubscriptionSinkorEventPublisherSink. Developers are encouraged to not throw exceptions when initialising Sinks. As a last-resort, one might store exceptions infailureCause. If the Sink is not entitled to initialise a givenaddress, one can just returnNOT_ATTEMPTED.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) booleaneventuallyConsistent(package private) ThrowablefailureCauseHolds the cause of a possible failure.(package private) booleaninitialisedTells whether the Sink was initialised or not.static EventBusSink.ResultNOT_ATTEMPTEDIdentifies that a given sink haven't tried to be initialised.(package private) StringrewrittenAddressThe local address which Kos will use to bridge the communication between Producers and Consumers.
-
Constructor Summary
Constructors Constructor Description Result()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static EventBusSink.Resultfailure(Throwable failure)Generates a result indicating a failure.StringgetRewrittenAddressOr(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 Detail
-
initialised
boolean initialised
Tells whether the Sink was initialised or not.
-
failureCause
Throwable failureCause
Holds the cause of a possible failure. It is null in case the initialisation succeeds.
-
rewrittenAddress
String rewrittenAddress
The local address which Kos will use to bridge the communication between Producers and Consumers.
-
eventuallyConsistent
boolean eventuallyConsistent
-
NOT_ATTEMPTED
public static final EventBusSink.Result 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.
-
-
Method Detail
-
failure
public static EventBusSink.Result failure(Throwable failure)
Generates a result indicating a failure. Failure results are terminal and might immediately stop the application.
-
succeededAtAddress
public static EventBusSink.Result succeededAtAddress(String rewrittenAddress)
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).
-
-