Interface RemoteStream<M extends BufferReader,P extends BufferWriter>

Type Parameters:
M - associated metadata with the stream
P - the payload type that can be pushed to the stream
All Known Implementing Classes:
RemoteStreamImpl

public interface RemoteStream<M extends BufferReader,P extends BufferWriter>
A RemoteStream is a unidirectional stream from the Broker to a Gateway. A RemoteStream allows consumers to push out payload of type RemoteStream to a Gateway.

NOTE: it's up to consumers of this API to interpret the metadata metadata() and its relation to the payload.

NOTE: implementations of the RemoteStream#push(Object, ErrorHandler) method are likely asynchronous. As such, errors handled via the RemoteStream.ErrorHandler may be executed after the initial call. Callers should be careful with the state they close on in the implementations of their RemoteStream.ErrorHandler.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Allows consumers of this API to specify error handling logic when a payload cannot be pushed out.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the stream's metadata
    void
    push(P payload, RemoteStream.ErrorHandler<P> errorHandler)
    Pushes the given payload to the stream.
  • Method Details

    • metadata

      M metadata()
      Returns the stream's metadata
    • push

      void push(P payload, RemoteStream.ErrorHandler<P> errorHandler)
      Pushes the given payload to the stream. Implementations of this are likely asynchronous; it's recommended that callers ensure that the given payload is immutable, and that the error handler does not close over any shared state.
      Parameters:
      payload - the data to push to the remote gateway
      errorHandler - logic to execute if the data could not be pushed to the underlying stream