Record Class MessageStoreBatch

java.lang.Object
java.lang.Record
io.fluxzero.common.tracking.MessageStoreBatch
Record Components:
messages - messages accepted by the scan filter
lastScannedIndex - index of the last scanned source message, regardless of whether it matched the filter
scannedSize - number of source messages scanned
byteLimited - whether scanning stopped because the next accepted message would exceed the byte budget

public record MessageStoreBatch(List<SerializedMessage> messages, Long lastScannedIndex, int scannedSize, boolean byteLimited) extends Record
Result of scanning a message store for a tracking batch.
  • Constructor Details

    • MessageStoreBatch

      public MessageStoreBatch(List<SerializedMessage> messages, Long lastScannedIndex, int scannedSize, boolean byteLimited)
      Creates an instance of a MessageStoreBatch record class.
      Parameters:
      messages - the value for the messages record component
      lastScannedIndex - the value for the lastScannedIndex record component
      scannedSize - the value for the scannedSize record component
      byteLimited - the value for the byteLimited record component
  • Method Details

    • scan

      public static MessageStoreBatch scan(Iterable<SerializedMessage> source, int maxSize, long maxBytes, Predicate<? super SerializedMessage> filter)
      Scans source messages until the source count or accepted-message byte budget is exhausted.

      The first accepted message is returned even when it exceeds maxBytes, so consumers can keep making progress.

      Parameters:
      source - source messages in index order
      maxSize - maximum number of source messages to scan
      maxBytes - maximum accepted-message payload bytes, or 0 for no byte limit
      filter - predicate deciding which messages enter the returned batch
      Returns:
      a batch with both accepted messages and source scan metadata
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • messages

      public List<SerializedMessage> messages()
      Returns the value of the messages record component.
      Returns:
      the value of the messages record component
    • lastScannedIndex

      public Long lastScannedIndex()
      Returns the value of the lastScannedIndex record component.
      Returns:
      the value of the lastScannedIndex record component
    • scannedSize

      public int scannedSize()
      Returns the value of the scannedSize record component.
      Returns:
      the value of the scannedSize record component
    • byteLimited

      public boolean byteLimited()
      Returns the value of the byteLimited record component.
      Returns:
      the value of the byteLimited record component