Interface IoMulti


public interface IoMulti
Create reactive stream from standard IO resources.
  • Method Details

    • outputStreamMulti

      static OutputStreamMulti outputStreamMulti()
      Create an OutputStream that provides the data written as a Multi.

      In case there is no demand, OutputStream.write(byte[], int, int) methods are blocked until downstream request for more data.

      Returns:
      new OutputStream implementing Multi
    • outputStreamMultiBuilder

      static IoMulti.OutputStreamMultiBuilder outputStreamMultiBuilder()
      Creates a builder of the OutputStream that provides data written as a Multi.
      Returns:
      the builder
      See Also:
    • multiFromStream

      static Multi<ByteBuffer> multiFromStream(InputStream inputStream)
      Create a Multi instance that publishes ByteBuffers from the given InputStream.

      InputStream is trusted not to block on read operations, in case InputStream is trusted not to block on read operations, in case it can't be assured use builder to specify executor for asynchronous waiting for blocking reads. IoMulti.multiFromStreamBuilder(is).executor(executorService).build().

      Parameters:
      inputStream - the Stream to publish
      Returns:
      Multi
    • multiFromStreamBuilder

      static IoMulti.MultiFromInputStreamBuilder multiFromStreamBuilder(InputStream inputStream)
      Creates a builder of the Multi from supplied InputStream.
      Parameters:
      inputStream - the Stream to publish
      Returns:
      the builder
    • multiFromByteChannel

      static Multi<ByteBuffer> multiFromByteChannel(ReadableByteChannel byteChannel)
      Creates a multi that reads data from the provided byte channel. The multi uses an executor service to process asynchronous reads. You can provide a custom executor service using multiFromByteChannelBuilder(java.nio.channels.ReadableByteChannel).
      Parameters:
      byteChannel - readable byte channel with data
      Returns:
      publisher of data from the provided channel
    • multiToByteChannel

      static Function<? super Multi<ByteBuffer>, ? extends Single<Void>> multiToByteChannel(WritableByteChannel writableChannel)
      Creates function consuming Multi<ByteBuffer> to supplied WritableByteChannel.
      Example usage:
      Multi.create(listOfByteBuffers)
           .map(s -> ByteBuffer.wrap(s.getBytes(StandardCharsets.UTF_8)))
           .to(IoMulti.multiToByteChannel(fileChannel))
           .await();
      
      Parameters:
      writableChannel - for consuming ByteBuffers from upstream
      Returns:
      mapper consuming Multi<ByteBuffer> and returning Single for observing asynchronous writing.
    • multiToByteChannelBuilder

      static IoMulti.MultiToByteChannelBuilder multiToByteChannelBuilder(WritableByteChannel byteChannel)
      Creates function consuming Multi<ByteBuffer> to supplied WritableByteChannel.
      Example usage:
      Multi.create(listOfByteBuffers)
           .map(s -> ByteBuffer.wrap(s.getBytes(StandardCharsets.UTF_8)))
           .to(IoMulti.multiToByteChannelBuilder(fileChannel)
                   .executor(customExecutor)
                   .build())
           .await();
      
      Parameters:
      byteChannel - for consuming ByteBuffers from upstream
      Returns:
      mapper consuming Multi<ByteBuffer> and returning Single for observing asynchronous writing.
    • writeToFile

      static IoMulti.MultiToByteChannelBuilder writeToFile(Path filePath)
      Creates function consuming Multi<ByteBuffer> to FileChannel opened from supplied Path.
      Example usage:
      Multi.create(listOfByteBuffers)
           .map(s -> ByteBuffer.wrap(s.getBytes(StandardCharsets.UTF_8)))
           .to(IoMulti.writeToFile(path)
                   .executor(customExecutor)
                   .build())
           .await();
      
      Parameters:
      filePath - file for writing all ByteBuffers from upstream to
      Returns:
      mapper consuming Multi<ByteBuffer> and returning Single for observing asynchronous writing.
    • multiFromByteChannelBuilder

      static IoMulti.MultiFromByteChannelBuilder multiFromByteChannelBuilder(ReadableByteChannel byteChannel)
      Creates a builder of Multi from provided ReadableByteChannel.
      Parameters:
      byteChannel - readable byte channel with data
      Returns:
      fluent API builder to configure additional details