Skip to content

Commit 73674c1

Browse files
committed
FIT testing: Convert stream exceptions
Change-Id: Id98ab4f0a6f8f8b1ea8f666a62a5d44e3342bfc0 Reviewed-on: https://review.couchbase.org/c/couchbase-jvm-clients/+/183717 Tested-by: David Nault <[email protected]> Reviewed-by: Graham Pople <[email protected]>
1 parent a6b94d0 commit 73674c1

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

kotlin-fit-performer/src/main/kotlin/com/couchbase/client/performer/kotlin/KotlinSdkCommandExecutor.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,9 @@ class KotlinSdkCommandExecutor(
292292
perRun,
293293
request.streamConfig.streamId,
294294
request.streamConfig,
295-
) { documentOrId ->
296-
processScanResult(request, documentOrId)
297-
}
295+
{ documentOrId -> processScanResult(request, documentOrId) },
296+
{ throwable -> convertException(throwable) }
297+
)
298298

299299
perRun.streamerOwner().addAndStart(streamer)
300300
result.setStream(

kotlin-fit-performer/src/main/kotlin/com/couchbase/stream/FluxStreamer.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ public class FluxStreamer<T> extends Streamer<T> {
2121
private final Flux<T> results;
2222
private final AtomicReference<BaseSubscriber> subscriberRef = new AtomicReference<>();
2323

24-
public FluxStreamer(Flux<T> results, PerRun perRun, String streamId, Config streamConfig, Function<T, Result> convert) {
25-
super(perRun, streamId, streamConfig, convert);
24+
public FluxStreamer(Flux<T> results,
25+
PerRun perRun,
26+
String streamId,
27+
Config streamConfig,
28+
Function<T, Result> convertResult,
29+
Function<Throwable, com.couchbase.client.protocol.shared.Exception> convertException) {
30+
super(perRun, streamId, streamConfig, convertResult, convertException);
2631
this.results = results;
2732
}
2833

@@ -35,7 +40,7 @@ public boolean isCreated() {
3540
public void run() {
3641
AtomicBoolean done = new AtomicBoolean(false);
3742

38-
BaseSubscriber<T> subscriber = new BaseSubscriber<T>() {
43+
BaseSubscriber subscriber = new BaseSubscriber<T>() {
3944
@Override
4045
protected void hookOnSubscribe(Subscription subscription) {
4146
if (streamConfig.hasAutomatically()) {
@@ -49,7 +54,7 @@ protected void hookOnSubscribe(Subscription subscription) {
4954
protected void hookOnNext(T value) {
5055
logger.info("Flux streamer {} sending one", streamId);
5156

52-
perRun.resultsStream().enqueue(convert.apply(value));
57+
perRun.resultsStream().enqueue(convertResult.apply(value));
5358
streamed.incrementAndGet();
5459
}
5560

@@ -79,8 +84,9 @@ protected void hookOnError(Throwable throwable) {
7984

8085
perRun.resultsStream().enqueue(Result.newBuilder()
8186
.setStream(com.couchbase.client.protocol.streams.Signal.newBuilder()
82-
// todo convert error
83-
.setError(com.couchbase.client.protocol.streams.Error.newBuilder().setStreamId(streamId)))
87+
.setError(com.couchbase.client.protocol.streams.Error.newBuilder()
88+
.setException(convertException.apply(throwable))
89+
.setStreamId(streamId)))
8490
.build());
8591
}
8692

0 commit comments

Comments
 (0)