eclipse-vertx / eclipse-vertx/vertx-sql-client

Proposal to expose PgClient functionality through R2DBC API

Open
#249 13 comments 30 reactions 0 assignees View on GitHub
help wanted
Dominant language
Java
Stars
912
Forks
212
Avg merge
17h 30m
Merged PRs (30d)
3

Description

[R2DBC](https://r2dbc.io) is an initiative to establish a common SPI for relational database drivers embracing reactive programming properties: Event-oriented, non-blocking, and ideally stream-oriented access to databases. R2DBC is built entirely on Reactive Streams defining a minimal API surface to be implemented by drivers without the need to re-implement common client functionality in every driver.

From an R2DBC perspective there are a couple of interfaces that could be implemented by using the following components of PgClient:

* `ConnectionFactory` -> `PgClient` and `PgPool`
* `Connection` -> `PgConnection`
* `Statement` -> Utility to build/prepare a statement, eventually calling `PgConnection.query(…)` or `PgConnection.preparedQuery(…)` methods
* `Result` -> `PgRowSet`
* `Row` -> (Pg) `Row`

## What is the benefit of doing so?

Benefits:

* Following an API that is well-suited for client developers without the need to entirely change how the client is supposed to work
* Participating in a growing client-ecosystem ([MyBatis](https://github.com/mybatis/mybatis-3/issues/1444), [draft](https://gist.github.com/kazuki43zoo), [JDBI](https://github.com/jdbi/jdbi/issues/1454), [Spring](https://github.com/spring-projects/spring-data-r2dbc)) with clients providing a humane API. Application developers get a choice of which client they want to use for specific use-cases.
* With the choice of clients, PgClient isn't required to provide additional functionality such as object mapping or SQL generation. That's up to the client.
* Choice of plug and play for a growing eco-system of drivers beyond [Postgres](https://github.com/reactiverse/reactive-pg-client) and [MySQL](https://github.com/mirromutth/r2dbc-mysql) (e.g. [H2](https://github.com/r2dbc/r2dbc-h2), Microsoft SQL Server) that can be used with vert.x.

Drawbacks:

* https://xkcd.com/927/
* Dependency on Reactive Streams (could be optional, still)
* Additional complexity by maintaining two driver frontends

Related ticket: #245.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.