Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal to expose PgClient functionality through R2DBC API #249

Open
mp911de opened this issue Feb 28, 2019 · 12 comments
Open

Proposal to expose PgClient functionality through R2DBC API #249

mp911de opened this issue Feb 28, 2019 · 12 comments

Comments

@mp911de
Copy link

mp911de commented Feb 28, 2019

R2DBC 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, draft, JDBI, Spring) 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 and MySQL (e.g. 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.

@mp911de
Copy link
Author

mp911de commented Mar 2, 2019

Here's a sketch how a PgPool could be exposed through the R2DBC API: https://gist.github.com/mp911de/9ea13939e8fd9a6b4ef138419f085715

It does not contain all the possible cases and requires a bit of work for prepared statements, however, it outlines the general idea.

@mp911de
Copy link
Author

mp911de commented Apr 5, 2019

@vietj did you had a chance to have look at https://gist.github.com/mp911de/9ea13939e8fd9a6b4ef138419f085715 outlining the intended PR? If so, I could start working on a pull request. WDYT?

@vietj
Copy link
Member

vietj commented Apr 5, 2019 via email

@pratikpparikh
Copy link

@mp911de nice work.

@Anisuka
Copy link

Anisuka commented Oct 30, 2019

@mp911de good work, any idea on when this may be added to mybatis ?

@mp911de
Copy link
Author

mp911de commented Oct 30, 2019

Check out https://gist.github.com/kazuki43zoo/2ede3dcbb857d7b23d685af08b5d4ea8 and mybatis/mybatis-3#1444. I’m not so much involved into MyBatis. However, MyBatis might need a bit of help to make R2DBC happen.

@jklingsporn
Copy link

jOOQ plans to support R2DBC within the next release and it would be nice to have a wrapper for vertx. @vietj have you any "official" plans/resources to implement R2DBC support/wrapper/client or do you consider this as a community project?
The biggest pain point I guess is the forced dependency to reactive streams in the API?

@lukaseder
Copy link

For the record, here's the link to the jOOQ issue: jOOQ/jOOQ#11700. It will ship with jOOQ 3.15 in Q2 2021. So far, no show stoppers have been found

@vietj
Copy link
Member

vietj commented Mar 25, 2021

we are not actively forward looking to implement R2DBC, but I think that anyone can provide an adapter project for this.

@moonaries90
Copy link

@mp911de good work, any idea on when this may be added to mybatis ?

https://github.com/moonaries90/mybatis-r2dbc-starter
I Just route about mybatis autoconfiguration. but i have no mysqlConnection to test, i used dev.miku packages. it is not very good

@lukaseder
Copy link

Another set of potential users of this integration (all via jOOQ):

While it seems that Red Hat isn't interested in moving forward with this (@vietj, why? Any background you can share on this decision? What would be needed to revert it?)

Is there any reason why @mp911de's work couldn't be published as one of these projects? https://r2dbc.io/drivers

@deusaquilus
Copy link

I'm curious about this too. Thinking about whether to implement a reactive driver for https://getquill.io/ but I can't support both R2DBC and VertX simultaneously. It's hard to move forward on this when there is no standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants