@Internal public interface SegmentProgressContext
The handle a SegmentProgressStrategy uses to observe and persist the progress of the single Segment it is bound to, provided to the strategy on creation.

The context owns token persistence: a strategy decides which TrackingToken is safe and calls persistProgress(TrackingToken, ProcessingContext), which performs the monotonic store and resets the claim-extension deadline. The strategy never touches the TokenStore directly. This keeps the store decision (and the claim-extension timing coupled to it) behind the context, so a strategy carries only the decision logic.

Internal API. This interface is marked Internal: it is the contract between a streaming processor and a progress strategy, consumed by advanced (and out-of-module) strategies rather than by end users, and its shape may change in a minor or patch release.

Since:
5.3.0
Author:
Allard Buijze
See Also:
  • Method Details

    • segment

      Segment segment()
      Returns the Segment this strategy is responsible for.
      Returns:
      the segment this strategy is bound to
    • lastConsumedToken

      @Nullable TrackingToken lastConsumedToken()
      Returns the highest TrackingToken handed to the handler so far for this segment, or null if nothing has been consumed yet.

      This is the position a strategy treats as "safe up to here" when deciding what to persist.

      Returns:
      the last consumed token, or null if nothing has been consumed yet
    • scheduleWorker

      void scheduleWorker()
      Wakes the segment's worker so a commit cycle runs. The lever a strategy uses to act on out-of-band work (such as an asynchronous checkpoint request) recorded between worker cycles; safe to call from any thread.
    • persistProgress

      CompletableFuture<Void> persistProgress(@Nullable TrackingToken candidate, ProcessingContext context)
      Persists candidate as this segment's progress within the given context, keeping the stored TrackingToken monotonic. A null, already-stored, or non-advancing token is ignored; a successful store also resets the claim-extension deadline. The store runs as part of context so it commits atomically with the surrounding batch (or release) transaction.
      Parameters:
      candidate - the token the strategy decided is safe, or null for nothing to persist
      context - the processing context whose transaction the store participates in
      Returns:
      a CompletableFuture completing when the store (if any) has been applied