Interface PositionStore

All Known Implementing Classes:
InMemoryPositionStore

public interface PositionStore
Interface for storing and retrieving Position objects representing the last processed message indexes per segment for a given consumer.

A Position tracks consumption progress on a per-segment basis. This enables distributed, parallel consumption and accurate replay/resume behavior in Fluxzero.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes any underlying resources held by the store.
    position(String consumer)
    Retrieves the full multi-segment position for the given consumer.
    resetPosition(String consumer, long lastIndex)
    Resets the position of the consumer for all segments to the given index.
    storePosition(String consumer, int[] segment, long lastIndex)
    Stores the latest processed index for a given segment range and consumer.
    storePosition(String consumer, Position current, int[] segment, long lastIndex)
    Stores the latest processed index for a given segment range and consumer, optionally using the caller's current view of the full position as additional context.
  • Method Details

    • storePosition

      CompletableFuture<Void> storePosition(String consumer, int[] segment, long lastIndex)
      Stores the latest processed index for a given segment range and consumer.
      Parameters:
      consumer - the consumer name (e.g., the tracking processor)
      segment - the segment range for which this index applies
      lastIndex - the last index successfully handled
      Returns:
      a future that completes when the position is stored
    • storePosition

      default CompletableFuture<Void> storePosition(String consumer, Position current, int[] segment, long lastIndex)
      Stores the latest processed index for a given segment range and consumer, optionally using the caller's current view of the full position as additional context.

      The supplied current position is the position the caller believes is currently stored for the consumer before applying this update. Implementations may ignore it or use it to optimize writes or perform optimistic concurrency checks before persisting the updated position.

      The default implementation delegates to storePosition(String, int[], long) and therefore ignores current.

      Parameters:
      consumer - the consumer name (e.g., the tracking processor)
      current - the caller's current view of the stored position for the consumer
      segment - the segment range for which this index applies
      lastIndex - the last index successfully handled
      Returns:
      a future that completes when the position is stored
    • resetPosition

      CompletableFuture<Void> resetPosition(String consumer, long lastIndex)
      Resets the position of the consumer for all segments to the given index.
      Parameters:
      consumer - the consumer name
      lastIndex - the new index to assign for all segments
      Returns:
      a future that completes when the reset is applied
    • position

      Position position(String consumer)
      Retrieves the full multi-segment position for the given consumer.
      Parameters:
      consumer - the consumer name
      Returns:
      the current Position of that consumer
    • close

      void close()
      Closes any underlying resources held by the store.