use of io.mycat.AsyncMycatDataContextImpl in project Mycat2 by MyCATApache.
the class PrepareExecutor method getMysqlPayloadObjectObservable.
@NotNull
public static Observable<MysqlPayloadObject> getMysqlPayloadObjectObservable(ArrayBindable bindable, AsyncMycatDataContextImpl newMycatDataContext, MycatRowMetaData rowMetaData) {
Observable<MysqlPayloadObject> rowObservable = Observable.<MysqlPayloadObject>create(emitter -> {
emitter.onNext(new MySQLColumnDef(rowMetaData));
try {
Object bindObservable;
bindObservable = bindable.bindObservable(newMycatDataContext);
Observable<Object[]> observable;
if (bindObservable instanceof Observable) {
observable = (Observable) bindObservable;
} else {
Enumerable<Object[]> enumerable = (Enumerable) bindObservable;
observable = toObservable(newMycatDataContext, enumerable);
}
observable.subscribe(objects -> emitter.onNext(new MysqlObjectArrayRow(objects)), throwable -> {
newMycatDataContext.endFuture().onComplete(event -> emitter.onError(throwable));
}, () -> {
CompositeFuture compositeFuture = newMycatDataContext.endFuture();
compositeFuture.onSuccess(event -> emitter.onComplete());
compositeFuture.onFailure(event -> emitter.onError(event));
});
} catch (Throwable throwable) {
CompositeFuture compositeFuture = newMycatDataContext.endFuture();
compositeFuture.onComplete(event -> emitter.onError(throwable));
}
});
return rowObservable;
}
Aggregations