Hello async my old friend

Let me present you vertx-jooq-async: the world’s first fully async and type-safe SQL code generation and execution tool for VertX™. Async? Wasn’t it asynchronous before? It was, but what the code did was wrapping JDBC-calls using Vertx’ executeBlocking-method, which just shifts the blocking code from one event loop to another (see also).

1r9aly

With this release however, things have changed. jOOQ is still used for generating code and creating type-safe queries, but code is executed utilizing vertx-mysql-postgresql-client. That library in turn is based on a non-blocking driver for MySQL and Postgres databases, so this time it is really non-blocking.

Although some stuff is yet missing – you should go and check out the github-page. Now.

vertx-jooq goes rx

After releasing a new version of your pet-project – what do you expect as a first reaction? Cheer? Love? Joy? No. People will ask for more. Welcome to the internet:

Clement Escoffier, vertx hero and avenger of unresolved github-issues however jumped in and added RX-Java support for vertx-jooq! Thanks to him, there is a new VertxDao that exposes various RX-like CRUD-methods:


public interface VertxDao<R extends UpdatableRecord<R>, P, T> extends DAO<R, P, T> {
/**
* Convenience method to execute any <code>DSLContext</code>-aware Function asynchronously
* using this DAO's <code>configuration</code>.
*
* @param function
* @param <X>
* @return Single
*/
<X> Single<X> executeAsync(Function<DSLContext, X> function);
/**
* Performs an async <code>INSERT</code> statement for a given POJO
*
* @param object The POJO to be inserted
* @return Completable which succeeds when the blocking method of this type succeeds or fails
* with an <code>DataAccessException</code> if the blocking method of this type throws an exception
* @see #insert(Object)
*/
Completable insertAsync(P object);
/**
* Performs an async <code>UPDATE</code> statement for a given POJO
*
* @param object The POJO to be updated
* @return Completable which succeeds when the blocking method of this type succeeds or fails
* with an <code>DataAccessException</code> if the blocking method of this type throws an exception
* @see #update(Object)
*/
Completable updateAsync(P object);
/**
* Performs an async <code>DELETE</code> statement for a given ID
*
* @param id The ID to be deleted
* @return Completable which succeeds when the blocking method of this type succeeds or fails
* with an <code>DataAccessException</code> if the blocking method of this type throws an exception
* @see #delete(Object…)
*/
Completable deleteByIdAsync(T id);
}

view raw

VertxDAO.java

hosted with ❤ by GitHub

This is cool! Also don’t forget to check the github-page for more details.