-
Simple API focusing on scalability and low overhead.
-
Reactive and non blocking which able to handle many database connections with a single thread.
-
Ranked #1 in the TechEmpower Benchmark Round 15 Single query benchmark.
-
Event driven
-
Lightweight
-
Built-in connection pooling
-
Prepared queries caching
-
Publish / subscribe using Postgres
LISTEN/NOTIFY
-
Batch and cursor support
-
Row streaming
-
java.util.stream.Collector
row set transformation -
Command pipeling
-
RxJava 1 and RxJava 2
-
Direct memory to object without unnecessary copies
-
Java 8 Date and Time
-
SSL/TLS
-
Unix domain socket
-
HTTP/1.x CONNECT, SOCKS4a or SOCKS5 proxy
Latest release is 0.11.0.
To use the client, add the following dependency to the dependencies section of your build descriptor:
-
Maven (in your
pom.xml
) for Vert.x 3.6.x:
<dependency>
<groupId>io.reactiverse</groupId>
<artifactId>reactive-pg-client</artifactId>
<version>0.11.0</version>
</dependency>
-
Gradle (in your
build.gradle
file) for Vert.x 3.6.x:
dependencies {
compile 'io.reactiverse:reactive-pg-client:0.11.0'
}
If you are using Vertx 3.5.x you should use instead 0.10.9
Then the code is quite straightforward:
// Pool options
PgPoolOptions options = new PgPoolOptions()
.setPort(5432)
.setHost("the-host")
.setDatabase("the-db")
.setUser("user")
.setPassword("secret")
.setMaxSize(5);
// Create the client pool
PgPool client = PgClient.pool(options);
// A simple query
client.query("SELECT * FROM users WHERE id='julien'", ar -> {
if (ar.succeeded()) {
PgResult<Row> result = ar.result();
System.out.println("Got " + result.size() + " results ");
} else {
System.out.println("Failure: " + ar.cause().getMessage());
}
// Now close the pool
client.close();
});
-
vertx-jooq: writing type safe queries and let them run at high speed using jOOQ, vertx and the reactive-pg-client.
The Reactive Postgres Client currently supports the following data types
_ | Value | Array | ||
---|---|---|---|---|
Postgres |
Java |
Supported |
JAVA |
Supported |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✕ |
|
|
✔ |
|
✕ |
|
|
✔ |
|
✕ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
|
|
✔ |
|
✔ |
The following types
MONEY, BIT, VARBIT, MACADDR, INET, CIDR, MACADDR8, XML, HSTORE, OID, VOID, TSQUERY, TSVECTOR
are not implemented yet (PR are welcome).
Snapshots are deploy in Sonatype OSS repository: https://oss.sonatype.org/content/repositories/snapshots/io/reactiverse/reactive-pg-client/
You can run tests with an external database:
-
the script
docker/postgres/resources/create-postgres.sql
creates the test data -
the
TLSTest
expects the database to be configured with SSL withdocker/postgres/resources/server.key
/docker/postgres/resources/server.cert`
You need to override the default connection uri for testing:
> mvn test -Dconnection.uri=postgres://$username:$password@$host:$port/$database
Note
|
unix domain sockets are not testable (yet). |
Create and run the following docker image:
> docker build -t test/postgres docker/postgres
> docker run --rm --name test-postgres -p 5432:5432 test/postgres
Run tests:
> mvn test -Dconnection.uri=postgres://postgres:postgres@localhost/postgres
Note
|
unix domain sockets are not testable (yet). |
The online and published documentation is in /docs
and is served by GitHub pages with Jekyll.
You can find the actual guide source in [src/main/docs/index.md](src/main/docs/index.md). At compilation time, this
source generates the jekyll/guide/java/index.md
.
The current documentation is in /jekyll
and can be preview using Docker and your browser
-
generate the documentation
-
mvn compile
to generatejekyll/guide/java/index.md
-
mvn site
to generate the javadoc injekyll/apidocs
-
-
run Jekyll
-
cd jekyll
-
docker-compose up
-
-
open your browser at http://localhost:4000