Interface ReplicationStream

All Superinterfaces:
Closeable

public interface ReplicationStream extends Closeable
Postgresql replication stream. Once established, the stream occupies the PostgresqlReplicationConnection until this stream is closed. This stream can be consumed by applying a mapping function using map(Function).
  • Method Details

    • close

      Mono<Void> close()
      Stop replication changes from server and free resources. After that connection can be reused. Also after closing the current stream this object cannot be used anymore. Subscribers will see a completion signal if they are still subscribed.
      Specified by:
      close in interface Closeable
      Returns:
      a Mono that termination is complete
    • isClosed

      boolean isClosed()
      Returns:
      true if replication stream was already closed, otherwise return false
    • map

      <T> Flux<T> map(Function<io.netty.buffer.ByteBuf, ? extends T> mappingFunction)
      Returns a mapping of the replication stream which is an unbounded stream.

      The data buffer is released after applying the mapping function.

      Unsubscribing from the stream will cancel consumption leaving protocol frames on the transport buffer. Close the ReplicationStream object to terminate the

      Type Parameters:
      T - the type of the mapped value
      Parameters:
      mappingFunction - the Function that maps a ByteBuf to a value
      Returns:
      a mapping of the data buffers that are the results of the replication stream
      Throws:
      IllegalArgumentException - if mappingFunction is null
    • getLastReceiveLSN

      LogSequenceNumber getLastReceiveLSN()
      Returns the last received LSN position.
      Returns:
      LSN position that was received with the last read via map(Function)
    • getLastFlushedLSN

      LogSequenceNumber getLastFlushedLSN()
      Returns the last flushed lsn send in update message to backend.
      Returns:
      location of the last WAL flushed to disk in the standby
    • getLastAppliedLSN

      LogSequenceNumber getLastAppliedLSN()
      Returns the last applied lsn send in update message to backed.
      Returns:
      location of the last WAL applied in the standby
    • setFlushedLSN

      void setFlushedLSN(LogSequenceNumber flushed)
      Sets the flushed LSN. The parameter will be send to backend on next update status iteration. Flushed LSN position help backend define which wal can be recycle.
      Parameters:
      flushed - not null location of the last WAL flushed to disk in the standby
    • setAppliedLSN

      void setAppliedLSN(LogSequenceNumber applied)
      Parameter used only physical replication and define which lsn already was apply on standby. Feedback will send to backend on next update status iteration.
      Parameters:
      applied - not null location of the last WAL applied in the standby