Skip to content

Commit 00f47d0

Browse files
committed
postman export and readme files are added.
1 parent cef5ad2 commit 00f47d0

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

clickhouse-r2dbc/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# clickhouse-r2dbc
2+
3+
This module provides r2dbc support to clickhouse-jdbc driver.
4+
5+
r2dbc link : https://r2dbc.io/
6+
7+
Sample code:
8+
```java
9+
ConnectionFactory connectionFactory = ConnectionFactories
10+
.get("r2dbc:clickhouse:http://{username}:{password}@{host}:{port}/{database}");
11+
12+
Mono.from(connectionFactory.create())
13+
.flatMapMany(connection -> connection
14+
.createStatement("select domain, path, toDate(cdate) as d, count(1) as count from clickdb.clicks where domain = :domain group by domain, path, d")
15+
.bind("domain", domain)
16+
.execute())
17+
.flatMap(result -> result
18+
.map((row, rowMetadata) -> String.format("%s%s[%s]:%d", row.get("domain", String.class),
19+
row.get("path", String.class),
20+
row.get("d", LocalDate.class),
21+
row.get("count", Long.class)) ))
22+
.doOnNext(System.out::println)
23+
.subscribe();
24+
```
25+
26+
for full example please check clickhouse-jdbc/examples/clickhouse-r2dbc-samples/clickhouse-r2dbc-spring-webflux-sample .
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#clickhouse-r2dbc-spring-webflux-sample
2+
3+
This is a sample rest api which will insert clicks and get the list of clicks per day.
4+
5+
In order to run the application;
6+
- Go clickhouse-jdbc/examples/clickhouse-r2dbc-samples/misc/docker and run;
7+
``` docker-compose up -d ```
8+
- Execute the table creation sql at clickhouse-jdbc/examples/clickhouse-r2dbc-samples/clickhouse-r2dbc-spring-webflux-sample/src/main/resources/init.sql .
9+
- Import the postman export clickhouse-jdbc/examples/clickhouse-r2dbc-samples/clickhouse-r2dbc-spring-webflux-sample/src/main/resources/postman .
10+
- Run the application by using Application.java .
11+
- Create some clicks by postman and list daily clicks per domain and path.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"info": {
3+
"_postman_id": "42544c65-9bda-4155-b00c-68bf62de19c2",
4+
"name": "clickhouse-r2dbc-sample",
5+
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
6+
},
7+
"item": [
8+
{
9+
"name": "List Clicks",
10+
"request": {
11+
"method": "GET",
12+
"header": [],
13+
"url": {
14+
"raw": "http://localhost:8080/clicks/google.com",
15+
"protocol": "http",
16+
"host": [
17+
"localhost"
18+
],
19+
"port": "8080",
20+
"path": [
21+
"clicks",
22+
"google.com"
23+
]
24+
}
25+
},
26+
"response": []
27+
},
28+
{
29+
"name": "Create Clicks",
30+
"request": {
31+
"method": "POST",
32+
"header": [],
33+
"body": {
34+
"mode": "raw",
35+
"raw": "{\n \"domain\" : \"google.com\",\n \"path\" : \"/mail\"\n}",
36+
"options": {
37+
"raw": {
38+
"language": "json"
39+
}
40+
}
41+
},
42+
"url": {
43+
"raw": "http://localhost:8080/clicks",
44+
"protocol": "http",
45+
"host": [
46+
"localhost"
47+
],
48+
"port": "8080",
49+
"path": [
50+
"clicks"
51+
]
52+
}
53+
},
54+
"response": []
55+
}
56+
]
57+
}

0 commit comments

Comments
 (0)