Git Product home page Git Product logo

micronaut-clickhouse's Introduction

Micronaut ClickHouse Configuration

Minimum required Java version Maven Central Java CI Quality Gate Status Coverage Maintainability Rating

This project includes integration between Micronaut and ClickHouse, autocompletion for configuration, health check.

Dependency 🚀

Gradle

implementation "com.github.goodforgod:micronaut-clickhouse:6.0.0"

Maven

<dependency>
    <groupId>com.github.goodforgod</groupId>
    <artifactId>micronaut-clickhouse</artifactId>
    <version>6.0.0</version>
</dependency>

JDBC

Official JDBC driver provides DataSource:

@Inject
private ClickHouseDataSource clickHouseDataSource;

@Named("clickhouse")
@Inject
private DataSource dataSource;

Configuration

Official Configuration supports all available ClickHouse driver settings.

Check ClickHouse Official settings file for info about all parameters.

clickhouse:
  jdbc:
    url: jdbc:clickhouse://localhost:8529/default?compress=1
    use-options: true             # default - true
    options:
      user: default
      password: default
    use-custom-options: true      # default - true
    custom-options:
      my-option: 1

R2DBC

Official R2DBC driver provides ConnectionFactory:

@Named("clickhouse")
@Inject
private ConnectionFactory connectionFactory;

Configuration

R2DBC configuration example:

clickhouse:
  r2dbc:
    url: r2dbc:clickhouse:http://localhost:8529/default?compress=1

Health Check

Health check for ClickHouse is provided for JDBC & R2DBC and is turned on by default.

Micronaut health check is part of Micronaut Health Endpoint.

Example of ClickHouse health:

{
  "name": "service",
  "status": "UP",
  "details": {
    "clickhouse-jdbc": {
      "name": "clickhouse",
      "status": "UP"
    },
    "clickhouse-r2dbc": {
      "name": "clickhouse",
      "status": "UP"
    }
  }
}

Where database name service is connected same as configuration says.

You can explicitly turn off health check or configure it.

endpoints:
  health:
   clickhouse:
     enabled: true               # default - true 
     jdbc:
       enabled: true             # default - true 
       timeout: 10000ms          # default - 10000ms
       retry: 2                  # default - 2
     r2dbc:
       enabled: true             # default - true 
       timeout: 10000ms          # default - 10000ms
       retry: 2                  # default - 2

Testing

For testing purposes you can use ClickHouse TestContainer library.

TestContainers allows you to use integration tests against real database in all docker friendly environments, check here for TestContainers.

Micronaut Compatability

Starting from version 6.0.0 library ships for Micronaut 4 & Java 17 is required.

Starting from version 3.0.0 library ships for Micronaut 3.

Starting from version 2.1.0 Java 11+ is required.

Starting from version 2.0.0 library ships for Micronaut 2 & Java 1.8 is required.

Last release for Micronaut 1 is version 1.0.2.

License

This project licensed under the Apache License 2.0 - see the LICENSE file for details.

micronaut-clickhouse's People

Contributors

goodforgod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

micronaut-clickhouse's Issues

Native connection is not @Inject'ing

Describe the bug
Can not inject native connection

To Reproduce
Steps to reproduce the behavior:
Just try to inject native driver connection results in:

  • Caused by: io.micronaut.context.exceptions.NoSuchBeanException: No bean of type [com.github.housepower.jdbc.settings.ClickHouseConfig] exists

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.