Skip to content

Commit

Permalink
[INLONG-10774][SDK] Optimize Cmake compilation script for CPP DataPro…
Browse files Browse the repository at this point in the history
…xy SDK (apache#10777)
  • Loading branch information
doleyzi authored Aug 13, 2024
1 parent ab88f0d commit 12c2c5d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ include_directories(src/client)
link_directories(${PROJECT_SOURCE_DIR}/third_party/lib)
link_directories(${PROJECT_SOURCE_DIR}/third_party/lib64)

add_subdirectory(third_party)
add_subdirectory(src/utils)
add_subdirectory(src/config)
add_subdirectory(src/core)
Expand All @@ -62,5 +61,5 @@ add_library(dataproxy_sdk STATIC ${UTILS} ${CONFIGS} ${CORE} ${MANAGER} ${GROUP}

set_target_properties(dataproxy_sdk PROPERTIES OUTPUT_NAME "dataproxy_sdk" PREFIX "")

target_link_libraries(dataproxy_sdk liblog4cplusS.a libsnappy.a libcurl.a)
target_link_libraries(dataproxy_sdk liblog4cplusS.a libsnappy.a libcurl.a libssl.a libcrypto.a)

21 changes: 12 additions & 9 deletions inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ dataproxy-sdk cpp version, used for sending data to dataproxy
* curl
* rapidjson
* asio
* log4cplus

## Build

Go to the dataproxy-sdk-cpp root, and run

```
./build_third_party.sh
./build.sh
```

Expand Down Expand Up @@ -74,24 +77,24 @@ Refer to `release/conf/config_example.json`.

1. First, init dataproxy-sdk, there are two ways you can choose:

- A) `int32_t tc_api_init(const char* config_file)`. Here, `config_file` is the path of your config file, and absolute
- A) `int32_t InitApi(const char* config_file)`. Here, `config_file` is the path of your config file, and absolute
path is recommended. Note that only once called is needed in one process.
- B) `int32_t tc_api_init(ClientConfig& client_config)`. Here, `client_config` is the pointer of a `ClientConfig`
object.

2. Then, send
data: `int32_t tc_api_send(const char* inlong_group_id, const char* inlong_stream_id, const char* msg, int32_t msg_len, UserCallBack call_back = NULL)`.
data: `int32_t Send(const char* inlong_group_id, const char* inlong_stream_id, const char* msg, int32_t msg_len, UserCallBack call_back = NULL)`.
If you set `call_back`, it will be callbacked if your data failed to send. See the signature of `UserCallBack`
in `release/inc/user_msg.h`.
in `src/core/sdk_msg.h`.

3. Finally, close sdk if no more data to be sent: `int32_t tc_api_close(int32_t max_waitms)`. Here, `max_waitms` is the
3. Finally, close sdk if no more data to be sent: `int32_t CloseApi(int32_t max_waitms)`. Here, `max_waitms` is the
interval of waiting data in memory to be sent.

4. Note, the above functions return 0 if success, otherwise it means failure. As for other return results, please refer
to `SDKInvalidResult` in `release/inc/tc_api.h`.
4. Note, the above functions return 0 if success, otherwise it m

5. eans failure. As for other return results, please refer
to `SDKInvalidResult` in `src/core/inlong_api.h`.

## Demo

1. Refer to `release/demo/send_demo.cc`.

2. Static lib is in `release/lib`. Header file is in `release/inc`.
2. Static lib is in `release/lib`. Header file is in `release/lib`.
11 changes: 1 addition & 10 deletions inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,8 @@

#!/bin/bash


# Install third-party components
cd ./third_party
cmake .
make

cd ../
rm -r build
mkdir build

# Compile project code
cd build
cmake ../
make
make -j4
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

#!/bin/bash

cd third_party
cmake .
make clean
make -j1

0 comments on commit 12c2c5d

Please sign in to comment.