Giter Site home page Giter Site logo

r2dbc-client's Introduction

This project is no longer being actively maintained.

Reactive Relational Database Connectivity Client (Archived)

This project is an exploration of what a Java API for relational database access with Reactive Streams might look like. It uses Project Reactor. It uses Jdbi as an inspiration.

Examples

A quick example of configuration and execution would look like:

PostgresqlConnectionConfiguration configuration = PostgresqlConnectionConfiguration.builder()
    .host("<host>")
    .database("<database>")
    .username("<username>")
    .password("<password>")
    .build();

R2dbc r2dbc = new R2dbc(new PostgresqlConnectionFactory(configuration));

r2dbc.inTransaction(handle ->
    handle.execute("INSERT INTO test VALUES ($1)", 100))

    .thenMany(r2dbc.inTransaction(handle ->
        handle.select("SELECT value FROM test")
            .mapResult(result -> result.map((row, rowMetadata) -> row.get("value", Integer.class)))))

    .subscribe(System.out::println);

Maven

Both milestone and snapshot artifacts (library, source, and javadoc) can be found in Maven repositories.

<dependency>
  <groupId>io.r2dbc</groupId>
  <artifactId>r2dbc-client</artifactId>
  <version>0.8.0.RC1</version>
</dependency>

Artifacts can bound found at the following repositories.

Repositories

<repository>
    <id>spring-snapshots</id>
    <name>Spring Snapshots</name>
    <url>https://repo.spring.io/snapshot</url>
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
</repository>
<repository>
    <id>spring-milestones</id>
    <name>Spring Milestones</name>
    <url>https://repo.spring.io/milestone</url>
    <snapshots>
        <enabled>false</enabled>
    </snapshots>
</repository>

License

This project is released under version 2.0 of the Apache License.

r2dbc-client's People

Contributors

gregturn avatar lukaseder avatar mirromutth avatar mp911de avatar nebhale avatar oshai avatar sdeleuze avatar spring-operator avatar sullis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

r2dbc-client's Issues

Using r2dbc-client with RS implementation besides Reactor

Currently the r2dbc-spi project only requires org.reactive-streams at the API level, and a DB vendor may implement the SPI using any RS implementation they choose.

However, r2dbc-client defines a hard dependency on reactor-core. This is unfortunate because r2dbc-client itself is a pretty lightweight wrapper around the SPI. All of the leg-work seems to be done by the SPI implementation. If I was using an SPI implementation where the DB vendor implementation chose Akka Streams or RxJava as their RS implementation, it would be nice to not have to pull in Reactor Core (a 1.5MB dependency) to do the client-level wrapper logic.

It would probably be overkill to put r2dbc-client APIs behind RS-impl agnostic interfaces, so I was wondering if the R2DBC folks would be open to the idea of alternative r2dbc client libraries that used different RS impls, such as r2dbc-client-rxjava or r2dbc-client-akka under the r2dbc org?

Is there any tutorial or hello world in Spring Boot how use r2dbc-client without Spring-Data

I read "r2dbc-client - client using pure Reactor (i.e. no Spring dependencies)." That fits quite well my problem. We have reactive stack but the data come from blocking database (Oracle). The problem is I see Spring-data for reactive approaches still not in release mode and it causes me issue while moving to production. The problem is that all example I have found from r2dbc-client uses somehow spring-data. Our microservices are bases in Spring world but I can't use any dependeny not delivery yet.

Your example from https://github.com/r2dbc/r2dbc-client seems still depending on Spring Data (PostgresqlConnectionConfiguration). I have nothing against Spring Data but I will be blocked from moving to production if the pom has milestone versions (not definitely release I mean).

Future of R2DBC Client

R2DBC started as an experiment to evaluate whether reactive programming and SQL databases can work together. R2DBC Client emerged as an artifact to make R2DBC usable without the need to use the SPI directly. A library that is providing higher-level abstraction, which is taking care of resource handling and a more humane API.

With the growth of drivers and the adoption of R2DBC in the Java eco-system, R2DBC Client deserves a place where it can evolve and reside in a maintained state. R2DBC is not opinionated about clients and client design in particular. Maintaining R2DBC Client by the R2DBC team and within the R2DBC organization influences how client library development is perceived.
R2DBC has a neutral position regarding client library design.

Therefore we want to transition R2DBC client into a new home that allows for the development and evolution of the client inspired by JDBI.

R2DBC API: Expose product name

ConnectionFactory should expose a product name, ideally as part of driver-metadata. Optionally, the metadata could also expose server-metadata.

The product name is a useful detail when configuring SQLErrorCodeSQLExceptionTranslator.

Require subscription on write operations?

In project reactor if you don't subscribe to a stream, nothing happens. This is fine if we are reading data, but is very un-intuitive if we are writing data to a database, where we typically don't care about any sort of feedback (unless an exception has been thrown).

Consider the following code example:

R2dbc r2dbc = // ...
r2dbc.inTransaction(handle -> handle.execute("INSERT INTO test VALUES ($1)", 100));

With the above code, it looks like we are inserting some data into a table, but nothing goes into the DB until we subscribe to the writer operation in some way, such as:

R2dbc r2dbc = // ...
r2dbc.inTransaction(handle -> handle.execute("INSERT INTO test VALUES ($1)", 100))
     .subscribe();

In JDBC we have two different operations for reads and writes (Statement.executeQuery() and Statement.executeUpdate() respectively), so perhaps we could do something similar in R2DBC? The difference being that read operations still need to be subscribed to, but write operations do not require a subscription.

R2DBC API: Provide Row.get(Object identifier)

When reading and mapping data into objects, it's common to have types which differ between the model and its persistent representation. We should have a method to read values and let the driver determine the data type.

Note: Ideally, we have Row.get(String identifier) and Row.get(int index) methods to tighten up the API contract and resolve ambiguities over the identifier.

Binding arrays for "IN" queries

As example:
List<Integer> age = new ArrayList(); age.add(10); age.add(20); age.add(30); r2dbc .withHandle(handle -> handle.select("select * from persons where age in ($1)") .bind("$1", ) .mapResult(result -> result.map(toWrapper())));

Add Blob/Clob Test

The Examples in the client should exercise the Blob/Clob functionality. It should be pretty straight forward to transport from r2dbc-spi's `Example.

PostgreSQL driver: Decoding null values fails

Reading a row in which a field contains a null value fails with

	Caused by: java.lang.NullPointerException
		at java.util.Objects.requireNonNull(Objects.java:203)
		at java.util.Optional.<init>(Optional.java:96)
		at java.util.Optional.of(Optional.java:108)
		at java.util.stream.FindOps$FindSink$OfRef.get(FindOps.java:193)
		at java.util.stream.FindOps$FindSink$OfRef.get(FindOps.java:190)
		at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
		at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
		at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
		at com.nebhale.r2dbc.postgresql.codec.DefaultCodecs.decode(DefaultCodecs.java:82)
		at com.nebhale.r2dbc.postgresql.PostgresqlRow.get(PostgresqlRow.java:84)
		at org.springframework.data.jdbc.core.function.EntityRowMapper.readFrom(EntityRowMapper.java:102)
		... 94 more

Ability too access mappable result for executing INSERT statement

Feature Request

Is your feature request related to a problem? Please describe

While playing around with r2dbc, I wanted to read the returned results from an INSERT. Given the table TEST with columns ID and DESCRIPTION, when insert a row like this (postgres):

handle.execute("INSERT INTO TEST VALUES (1$, $2) RETURNING ID", 1, "bla")

I found out that that execute() always maps the result into an integer that shows the number of affected rows. I was wishing to be able to read the result of the query. I am aware that not all databases supports RETURNING in INSERT

Describe the solution you'd like

being able to access the result using .mapResult or .map

Describe alternatives you've considered

An alternative way to get the ID is to pre-set from the provided value. Another solution for sequence id is to read them using a select query before executing the INSERT statement

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.