Giter Club home page Giter Club logo

achord's Introduction

Build Status

Java 10 is a minimal compatible version because reactive bridge based on JEP 266 and Java 9 reached EOL, so we switched to actual 10 version starting from 0.2.0 driver version.

Setup

Maven

Add dependency into your pom.xml

<dependency>
  <groupId>com.github.mangelion</groupId>
  <artifactId>achord</artifactId>
  <version>0.2.1</version>
</dependency>

Gradle

Add following dependency into your build.gradle script

compile "com.github.mangelion:achord:0.2.1"

Usage

At this point only one mode is ready to using. That is outbound mode where data streams from client to server. More options coming soon, don't hesitate to create issue if you need another one.

We suppose that only one ClickHouseClient per server will be used. It means that you should create only one instance for every ClickHouse cluster.

Client comes with bunch of configurable options. So start with ClickHouseClient.bootstrap() and change those defaults that you need. For instance we have ClickHouse cluster defined on awesome-ch-cluster-ea1.amazon.com at port 8999 and want to connect as user customer to database examples with our client like below:

var client = ClickHouseClient.bootstrap()
                                .remote("awesome-ch-cluster-ea1.amazon.com", 8999)
                                .username("customer")
                                .database("examples");

This is cheap client creation that doesn't block your cpu for a long time. After client is created we ready to use it. Let us send some numbers to server:

// table created as `create table examples.numbers(date Date DEFAULT toDate(now()), number UInt32 number)`  
// Flux is a part of projectreactor library and you can use any other provider like akka-streams, rxjava2, and so on  
client.sendData("INSERT INTO examples.test(number)", Flux.range(0, 1024).map(i -> new Object[] { i }))
          .subscribe();

Thats all. Client prepares new connection, sends your data, and notifies subscriber with error or complete signal (no any other expected from sendData).

If you wish to use compression, enable it on bootstrap phase with .compression(CompressionMethod.LZ4) (LZ4 only one mode that is supported in this release)

We hardly work on zstd, lz4hc and different combination of this methods in our driver.

You can find more examples in ClickHouseClientTest.

OS Based Network stack.

As Netty provides KQueue/Epool based mechanism like drop-in-replacement of Java.NIO interface, Achord tries to use it whenever it possible. First of all, it looks into Epool/Kqueue classes that might be presented in classpath. (Please, consult with Netty documentation if you wish to add it manually.)

When there are no epool/kqueue libraries in classpath Achord recedes onto Java.NIO if strictNativeNetwork option not used, or set to false.

achord's People

Contributors

camelion avatar dpoluyanov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

achord's Issues

Provide backport for Java 8 users

As we can see the majority of reactive-libraries are Java 8 based.
So we should provide solution for users who stay on that Java version (at least at end of life for Java 8 release).
I suggest to prepare library with JEP-266 changes and reassemble library with Java 8 binary compatibility. At this point only java.util.concurrent.Flow is proposed to include into that external library.

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.