@Override public <T> CompletableFuture<T> inTransaction(Func1<SQLConnection, CompletableFuture<T>> func1) { Completable<T> ret = new Completable<>(); beginTransaction().thenAccept(newTransaction -> executeFuncAndCommit(func1, ret, newTransaction)); return ret; }
@Override public <T> CompletableFuture<T> inTransaction(Func1<SQLConnection, CompletableFuture<T>> func1) { Completable<T> ret = new Completable<>(); beginTransaction().thenAccept(newTransaction -> executeFuncAndCommit(func1, ret, newTransaction)); return ret; }
public <T> Promise.Completable<T> asyncTransaction(Func2<Connection, JDBCHelper, T> func) { Promise.Completable<T> c = new Promise.Completable<>(); executorService.submit(() -> { try { c.succeeded(executeTransaction(func)); } catch (Throwable t) { c.failed(t); } }); return c; }
@Override public CompletableFuture<HTTPTunnelConnection> upgradeHTTPTunnel() { Promise.Completable<HTTPTunnelConnection> c = new Promise.Completable<>(); tunnelConnectionPromise = c; return c; }
public Promise.Completable<HTTPClientConnection> connect(String host, int port) { Promise.Completable<HTTPClientConnection> completable = new Promise.Completable<>(); connect(host, port, completable); return completable; }
/** * Submit an HTTP request. * * @return The CompletableFuture of HTTP response. */ public Promise.Completable<SimpleResponse> submit() { submit(new Promise.Completable<>()); return future; }
/** * Submit an HTTP request. * * @return The CompletableFuture of HTTP response. */ public Promise.Completable<SimpleResponse> submit() { submit(new Promise.Completable<>()); return future; }
@Override public CompletableFuture<Boolean> writeToFuture(ByteBuffer[] byteBuffer) { Promise.Completable<Boolean> c = new Promise.Completable<>(); write(byteBuffer, () -> c.succeeded(true), c::failed); return c; }
@Override public CompletableFuture<Boolean> writeToFuture(ByteBuffer byteBuffer) { Promise.Completable<Boolean> c = new Promise.Completable<>(); write(byteBuffer, () -> c.succeeded(true), c::failed); return c; }
public <T> Promise.Completable<T> async(Connection connection, Func2<Connection, JDBCHelper, T> func) { Promise.Completable<T> c = new Promise.Completable<>(); executorService.submit(() -> { try { c.succeeded(func.call(connection, this)); } catch (Throwable t) { c.failed(t); } }); return c; }
public Promise.Completable<HTTPClientConnection> connect(String host, int port) { Promise.Completable<HTTPClientConnection> completable = new Promise.Completable<>(); connect(host, port, completable); return completable; }
@Override public <T> Mono<T> inTransaction(Func1<ReactiveSQLConnection, Mono<T>> func1) { return Mono.fromCompletionStage(sqlConnection.inTransaction(conn -> { Promise.Completable<T> completable = new Promise.Completable<>(); func1.call(this) .subscribe(completable::succeeded, completable::failed); return completable; })); }
@Override public <T> Mono<T> newTransaction(Func1<ReactiveSQLConnection, Mono<T>> func1) { return Mono.fromCompletionStage(sqlClient.newTransaction(conn -> { Promise.Completable<T> completable = new Promise.Completable<>(); func1.call(new ReactiveSQLConnectionAdapter(conn)) .subscribe(completable::succeeded, completable::failed); return completable; })); }
@Override public CompletableFuture<Boolean> writeToFuture(ByteBuffer[] byteBuffer) { Promise.Completable<Boolean> c = new Promise.Completable<>(); write(byteBuffer, () -> c.succeeded(true), c::failed); return c; }
@Override public <T> Mono<T> inTransaction(Func1<ReactiveSQLConnection, Mono<T>> func1) { return Mono.fromCompletionStage(sqlConnection.inTransaction(conn -> { Promise.Completable<T> completable = new Promise.Completable<>(); func1.call(this) .subscribe(completable::succeeded, completable::failed); return completable; })); }
public Promise.Completable<Connection> asyncGetConnection() { Promise.Completable<Connection> c = new Promise.Completable<>(); executorService.submit(() -> { try { c.succeeded(getConnection()); } catch (Throwable t) { c.failed(t); } }); return c; }
public CompletableFuture<TcpConnection> connect(String host, int port) { Promise.Completable<TcpConnection> promise = new Promise.Completable<>(); connect(host, port, promise); return promise; }
@Override public CompletableFuture<Boolean> writeToFuture(ByteBuffer byteBuffer) { Promise.Completable<Boolean> c = new Promise.Completable<>(); write(byteBuffer, () -> c.succeeded(true), c::failed); return c; }
public <T> Promise.Completable<T> async(Connection connection, Func2<Connection, JDBCHelper, T> func) { Promise.Completable<T> c = new Promise.Completable<>(); executorService.submit(() -> { try { c.succeeded(func.call(connection, this)); } catch (Throwable t) { c.failed(t); } }); return c; }
@Override public <T> Mono<T> newTransaction(Func1<ReactiveSQLConnection, Mono<T>> func1) { return Mono.fromCompletionStage(sqlClient.newTransaction(conn -> { Promise.Completable<T> completable = new Promise.Completable<>(); func1.call(new ReactiveSQLConnectionAdapter(conn)) .subscribe(completable::succeeded, completable::failed); return completable; })); }