Code Monkey home page Code Monkey logo

reactive-pg-client's Introduction

Reactive Postgres Client

Build Status

  • 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.

Features

  • 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

Usage

To use the client, add the following dependency to the dependencies section of your build descriptor:

  • Maven (in your pom.xml):

<dependency>
  <groupId>io.reactiverse</groupId>
  <artifactId>reactive-pg-client</artifactId>
  <version>0.9.0</version>
</dependency>
  • Gradle (in your build.gradle file):

dependencies {
  compile 'io.reactiverse:reactive-pg-client:0.8.0'
}

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();
});

Javadoc

Supported Data Types

The Reactive Postgres Client currently supports the following data types

_ Value Array

Postgres

Java

Supported

JAVA

Supported

BOOLEAN

j.l.Boolean

j.l.Boolean[]

INT2

j.l.Short

j.l.Short[]

INT4

j.l.Integer

j.l.Integer[]

INT8

j.l.Long

j.l.Long[]

FLOAT4

j.l.Float

j.l.Float[]

FLOAT8

j.l.Double

j.l.Double[]

CHAR

j.l.Character

j.l.Character[]

VARCHAR

j.l.String

j.l.String[]

TEXT

j.l.String

j.l.String[]

ENUM

j.l.String

j.l.String[]

NAME

j.l.String

j.l.String[]

NUMERIC

i.r.p.Numeric

i.r.p.Numeric[]

UUID

j.u.UUID

j.u.UUID[]

DATE

j.t.LocalDate

j.t.LocalDate[]

TIME

j.t.LocalTime

j.t.LocalTime[]

TIMETZ

j.t.OffsetTime

j.t.OffsetTime[]

TIMESTAMP

j.t.LocalDateTime

j.t.LocalDateTime[]

TIMESTAMPTZ

j.t.OffsetDateTime

j.t.OffsetDateTime[]

INTERVAL

i.r.p.d.Interval

i.r.p.d.Interval[]

BYTEA

i.v.c.b.Buffer

i.v.c.b.Buffer[]

JSON

i.r.p.Json

i.r.p.Json[]

JSONB

i.r.p.Json

i.r.p.Json[]

The following types

SERIAL2, SERIAL4, SERIAL8, MONEY, BIT, VARBIT, MACADDR, INET, CIDR, MACADDR8, XML, POINT, PATH, BOX, LINE, POLYGON, LSEG, CIRCLE, HSTORE, OID, VOID, UNKOWN, TSQUERY, TSVECTOR

are not implemented yet (PR are welcome).

Snapshots

License

Apache License - Version 2.0

Developers

Documentation

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](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 generate jekyll/guide/java/index.md

    • mvn site to generate the javadoc in jekyll/apidocs

  • run Jekyll

    • cd jekyll

    • docker-compose up

  • open your browser at http://localhost:4000

reactive-pg-client's People

Contributors

vietj avatar emadalblueshi avatar billyyccc avatar pratikpparikh avatar pmlopes avatar jklingsporn avatar

Watchers

James Cloos avatar  avatar

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.