Package io.oxia.client.api
Interface RangeScanConsumer
public interface RangeScanConsumer
Callback used by
AsyncOxiaClient.rangeScan(String, String, RangeScanConsumer) to deliver
records, errors, and the completion signal for a streaming range scan.
Exactly one of onError(Throwable) or onCompleted() is invoked per scan, and
always after the final onNext(GetResult) call. Returning false from
onNext stops iteration early; the underlying server stream is cancelled and onCompleted() is invoked once.
client.rangeScan("a", "z", new RangeScanConsumer() {
public boolean onNext(GetResult result) {
process(result);
return true; // return false to abort iteration early
}
public void onError(Throwable t) { log.warn("scan failed", t); }
public void onCompleted() { log.info("scan finished"); }
});
For a synchronous, iterator-style alternative, see SyncOxiaClient.rangeScan(String, String) which returns a CloseableIterable.
-
Method Summary
Modifier and TypeMethodDescriptionvoidInvoked when the range scan operation completes.voidInvoked when an error occurs during the range scan operation.booleanInvoked for each record returned by the range scan operation.
-
Method Details
-
onNext
Invoked for each record returned by the range scan operation.- Parameters:
result- The GetResult for the record.- Returns:
trueto keep receiving records,falseto stop the iteration. Whenfalseis returned, the underlying server stream is cancelled, no furtheronNext(io.oxia.client.api.GetResult)invocations will be made, andonCompleted()will be invoked once.
-
onError
Invoked when an error occurs during the range scan operation.- Parameters:
throwable- the exception that occurred.
-
onCompleted
void onCompleted()Invoked when the range scan operation completes.
-