Interface LogStreamWriter

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface LogStreamWriter
  • Method Details

    • canWriteEvents

      default boolean canWriteEvents(int eventCount, int batchSize)
      Returns true if the given eventCount with the given batchLength could potentially be written, false otherwise.
      Parameters:
      eventCount - the potential event count we want to check
      batchSize - the potential batch Size (in bytes) we want to check
      Returns:
      true if the event count with corresponding size could be written, false otherwise
    • tryWrite

      default Either<LogStreamWriter.WriteFailure,Long> tryWrite(WriteContext context, LogAppendEntry appendEntry)
      Attempts to write the event to the underlying stream.
      Parameters:
      appendEntry - the entry to write
      Returns:
      the event position, a negative value if fails to write the event, or 0 if the value is empty
    • tryWrite

      default Either<LogStreamWriter.WriteFailure,Long> tryWrite(WriteContext context, LogAppendEntry appendEntry, long sourcePosition)
    • tryWrite

      default Either<LogStreamWriter.WriteFailure,Long> tryWrite(WriteContext context, List<LogAppendEntry> appendEntries)
      Attempts to write the events to the underlying stream. This method is atomic, either all events are written, or none are.
      Parameters:
      appendEntries - a set of entries to append; these will be appended in the order
      Returns:
      the last (i.e. highest) event position, a negative value if fails to write the events, or 0 if the batch is empty
    • tryWrite

      Either<LogStreamWriter.WriteFailure,Long> tryWrite(WriteContext context, List<LogAppendEntry> appendEntries, long sourcePosition)
      Attempts to write the events to the underlying stream. This method is atomic, either all events are written, or none are.
      Parameters:
      appendEntries - a list of entries to append; append order is maintained
      sourcePosition - a back-pointer to the record whose processing created these entries
      Returns:
      the last (i.e. highest) event position, a negative value if fails to write the events, or 0 if the batch is empty