tree: 46c53874de3ca1f535b4dcacd7c5eb2031a0070b [path history] [tgz]
  1. release/
  2. src/
  3. test/
  4. third_party/
  5. build.sh
  6. CMakeLists.txt
  7. README.md
inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-cpp/README.md

DataProxy-SDK-cpp

dataproxy-sdk cpp version, used for sending data to dataproxy

Prerequisites

  • CMake 3.1+
  • snappy
  • curl
  • rapidjson
  • asio

Build

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

./build.sh

Config Parameters

Refer to release/conf/config_example.json.

namedefault valuedescription
thread_num10number of network sending threads
inlong_group_ids""the list of inlong_group_id, seperated by commas, such as “b_inlong_group_test_01, b_inlong_group_test_02”
enable_groupId_isolationfalsewhether different groupid data using different buffer pools inside the sdk
buffer_num_per_groupId5number of buffer pools of each groupid
enable_packtruewhether multiple messages are packed while sending to dataproxy
pack_size4096byte, pack messages and send to dataproxy when the data in buffer pool exceeds this value
ext_pack_size16384byte, maximum length of a message
enable_ziptruewhether zip data while sending to dataproxy
min_ziplen512byte, minimum zip len
enable_retrytruewhether do resend while failed to send data
retry_ms3000millisecond, resend interval
retry_num3maximum resend times
max_active_proxy3maximum number of established connections with dataproxy
max_buf_pool50 *1024* 1024byte, the size of buffer pool
log_num10maximum number of log files
log_size10MB, maximum size of one log file
log_level2log level: trace(4)>debug(3)>info(2)>warn(1)>error(0)
log_file_type2type of log output: 2->file, 1->console
log_path./logs/log path
proxy_update_interval10interval of requesting and updating dataproxy lists from manager
proxy_cfg_preurlhttp://127.0.0.1:8099/inlong/manager/openapi/dataproxy/getIpListthe url of manager openapi
need_authfalsewhether need authentication while interacting with manager
auth_id""authenticate id if need authentication
auth_key""authenticate key if need authentication

Usage

  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 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.
  1. 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). 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.

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

  3. 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.

Demo

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

  2. Static lib is in release/lib. Header file is in release/inc.