Interface PushEventSource<T>

  • Type Parameters:
    T - The payload type
    All Known Subinterfaces:
    SimplePushEventSource<T>
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @ConsumerType
    @FunctionalInterface
    public interface PushEventSource<T>
    An event source. An event source can open a channel between a source and a consumer. Once the channel is opened (even before it returns) the source can send events to the consumer. A source should stop sending and automatically close the channel when sending an event returns a negative value, see PushEventConsumer.ABORT. Values that are larger than 0 should be treated as a request to delay the next events with those number of milliseconds.
    • Method Detail

      • open

        java.lang.AutoCloseable open​(PushEventConsumer<? super T> aec)
                              throws java.lang.Exception
        Open the asynchronous channel between the source and the consumer. The call returns an AutoCloseable. This can be closed, and should close the channel, including sending a Close event if the channel was not already closed. The returned object must be able to be closed multiple times without sending more than one Close events.
        Parameters:
        aec - the consumer (not null)
        Returns:
        a AutoCloseable that can be used to close the stream
        Throws:
        java.lang.Exception