Class PubSubSplitReaders

java.lang.Object
io.github.flink.gcp.connector.testutils.pubsub.PubSubSplitReaders

@Internal public final class PubSubSplitReaders extends Object
Fetch-loop helpers for driving a Pub/Sub SplitReader directly in tests, typed against the flink-connector-base interface so the connector's reader class never crosses the module boundary.
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<com.google.pubsub.v1.PubsubMessage>
    fetchUntil(org.apache.flink.connector.base.source.reader.splitreader.SplitReader<com.google.pubsub.v1.PubsubMessage,?> reader, int expected, Duration timeout)
    Fetches until expected distinct messages have been collected or the timeout elapses, returning them in arrival order.
    static List<String>
    payloads(List<com.google.pubsub.v1.PubsubMessage> messages)
    Returns the messages' UTF-8 payloads, in order.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • fetchUntil

      public static List<com.google.pubsub.v1.PubsubMessage> fetchUntil(org.apache.flink.connector.base.source.reader.splitreader.SplitReader<com.google.pubsub.v1.PubsubMessage,?> reader, int expected, Duration timeout) throws Exception
      Fetches until expected distinct messages have been collected or the timeout elapses, returning them in arrival order. Distinct by split and message id — message ids are only unique within a topic — because delivery is at-least-once: a wait long enough to span the acknowledgement deadline can legitimately see the same message twice, and a duplicate must dedupe rather than crowd out a message still to arrive. A fetch blocks until data arrives, so a waker nudges the reader once the deadline passes; an emptiness check ( expected = Integer.MAX_VALUE) holds its full window.
      Throws:
      Exception
    • payloads

      public static List<String> payloads(List<com.google.pubsub.v1.PubsubMessage> messages)
      Returns the messages' UTF-8 payloads, in order.