Skip to content

Commit 6ca84bf

Browse files
committed
docs: add integration examples
Signed-off-by: ik <[email protected]>
1 parent be77606 commit 6ca84bf

File tree

12 files changed

+134
-4
lines changed

12 files changed

+134
-4
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ endif()
101101

102102
if(OPENGEMINI_BUILD_EXAMPLE)
103103
message(STATUS "Generating examples")
104-
add_subdirectory(examples)
104+
add_subdirectory(examples/usage)
105105
endif()
106106

107107
if (OPENGEMINI_BUILD_DOCUMENTATION)

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ OpenGemini is a cloud-native distributed time series database, find more informa
4242
- [GoogleTest](https://github.com/google/googletest) (*optional*, for building unit tests)
4343

4444
## Integration
45+
46+
> For a whole example project, please check out `examples/integration` directory.
47+
4548
### CMake FetchContent
4649
It is recommended to integrate with OpenGeminiCxx using CMake's [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html).
4750

@@ -90,7 +93,7 @@ You may also need to link against any necessary dependencies to your program man
9093
```
9194

9295
## Quick Start
93-
Below are a few examples show how to use some of the main features of the library. For more example code, please check out `examples` directory;
96+
> Below are a few examples show how to use some of the main features of the library. For more example code, please check out `examples/usage` directory.
9497
### Query data from the server
9598
```cpp
9699
#include <iostream>

README_CN.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ OpenGemini 是一款云原生分布式时序数据库。获取更多信息,请
4343

4444

4545
## 与项目集成
46+
47+
> 您可以通过`examples/integration`目录查看完整的示例工程。
48+
4649
### CMake FetchContent
4750
我们推荐使用CMake [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) 来将OpenGeminiCxx集成到您的项目中。
4851

@@ -81,7 +84,7 @@ target_link_libraries(YourApp PRIVATE OpenGeminiCxx::Client)
8184
```
8285

8386
### Header-Only
84-
> **注意:** 尽管OpenGeminiCxx可以当作纯头文件引用,但我们仍建议使用预编译好的版本以减少构建时间。
87+
> **注意:** 尽管OpenGeminiCxx可以作为纯头文件引用,但我们仍建议使用预编译好的版本以减少构建时间。
8588
8689
下载[OpenGeminiCxx](https://github.com/openGemini/opengemini-client-cpp/releases),然后将`/path/to/opengemini-client-cpp/include`添加至工程的包含路径中。
8790

@@ -91,7 +94,7 @@ target_link_libraries(YourApp PRIVATE OpenGeminiCxx::Client)
9194
```
9295

9396
## 快速上手
94-
下列示例代码简单演示了这个库的一些主要特性,您可以通过`examples`目录查看更多的示例代码。
97+
> 下列示例代码简单演示了这个库的一些主要特性,您可以通过`examples/usage`目录查看更多的示例代码。
9598
### 从服务端查询数据
9699
```cpp
97100
#include <iostream>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2024 openGemini Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
cmake_minimum_required(VERSION 3.12)
16+
17+
project(ExampleFetchContent)
18+
19+
# You can set option variables here to control configurations.
20+
#
21+
# Enable TLS support:
22+
# set(OPENGEMINI_ENABLE_SSL_SUPPORT ON)
23+
# Build OpenGeminiCxx as a shared library:
24+
# set(OPENGEMINI_BUILD_SHARED_LIBS ON)
25+
#
26+
# For details about all the options, see README file.
27+
28+
# Declare OpenGeminiCxx and make it available
29+
include(FetchContent)
30+
FetchContent_Declare(OpenGeminiCxx
31+
GIT_REPOSITORY https://github.com/openGemini/opengemini-client-cpp
32+
GIT_TAG main
33+
)
34+
FetchContent_MakeAvailable(OpenGeminiCxx)
35+
36+
add_executable(YourApp main.cpp)
37+
38+
# Link OpenGeminiCxx's target against to your target.
39+
target_link_libraries(YourApp PRIVATE OpenGeminiCxx::Client)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2024 openGemini Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <iostream>
16+
17+
#include <opengemini/Client.hpp>
18+
#include <opengemini/ClientConfigBuilder.hpp>
19+
20+
int main(int argc, char** argv)
21+
{
22+
opengemini::Client client{ opengemini::ClientConfigBuilder()
23+
.AppendAddress({ "127.0.0.1", 8086 })
24+
.Finalize() };
25+
26+
std::cout << "OpenGemini server's version: " << client.Ping(0) << std::endl;
27+
28+
return 0;
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright 2024 openGemini Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
cmake_minimum_required(VERSION 3.12)
16+
17+
project(ExampleFetchContent)
18+
19+
# If you installed OpenGeminiCxx to a custom directory,
20+
# you may need to tell CMake where to search the library such as:
21+
# setting root variable before calling find_package():
22+
# set(OpenGeminiCxx_ROOT /path/to/the/installation)
23+
# or specifying the root variable while running cmake:
24+
# $ cmake -DOpenGeminiCxx_ROOT=/path/to/the/installation
25+
# or adding the directory to the CMAKE_PREFIX_PATH.
26+
#
27+
# For more usage about find_package() check: https://cmake.org/cmake/help/latest/command/find_package.html
28+
29+
find_package(OpenGeminiCxx REQUIRED)
30+
31+
add_executable(YourApp main.cpp)
32+
33+
# Link OpenGeminiCxx's target against to your target.
34+
target_link_libraries(YourApp PRIVATE OpenGeminiCxx::Client)
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2024 openGemini Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <opengemini/Client.hpp>
16+
17+
int main(int argc, char** argv)
18+
{
19+
opengemini::Client client{ {} };
20+
21+
return 0;
22+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)