Package kos.api

Class EventBusSink.Result

  • Enclosing interface:
    EventBusSink

    public static class EventBusSink.Result
    extends Object
    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 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 return Result.NOT_ATTEMPTED whenever the Sink cannot handle the informed address.
    • Constructor Detail

      • Result

        public Result()
    • Method Detail

      • getRewrittenAddressOr

        public String getRewrittenAddressOr​(String defaultValue)
      • 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 informed rewrittenAddress will 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 informed rewrittenAddress will 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 like succeededAtAddress(String, Boolean).