1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 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 16 #ifndef RPC_RPC_H 17 #define RPC_RPC_H 18 19 #include <functional> 20 #include <mutex> 21 #include "trace_streamer/trace_streamer_selector.h" 22 #include "sdk/sdk_data_parser.h" 23 namespace SysTuning { 24 namespace TraceStreamer { 25 class DemoRpcServer { 26 public: 27 using ResultCallBack = std::function<void(const std::string /* result */, int32_t, int32_t)>; 28 using TraceRangeCallbackFunction = std::function<void(const std::string)>; 29 // In order to bind HTTP, maintain a unified interface, even if some parameters are useless 30 bool DemoSqlOperate(const uint8_t* data, size_t len, ResultCallBack resultCallBack); 31 bool DemoSqlQuery(const uint8_t* data, size_t len, ResultCallBack resultCallBack); 32 bool DemoReset(const uint8_t* data, size_t len, ResultCallBack resultCallBack); 33 void DemoCancelSqlQuery(); 34 35 // only for wasm, no callback 36 int32_t DemoWasmSqlQuery(const uint8_t* data, size_t len, uint8_t* out, int32_t outLen); 37 int32_t DemoWasmSqlQueryWithCallback(const uint8_t* data, size_t len, ResultCallBack callback) const; 38 int32_t DemoWasmGetPluginNameWithCallback(const uint8_t* data, size_t len) const; 39 40 public: 41 std::unique_ptr<TraceStreamerSelector> demoTs_ = std::make_unique<TraceStreamerSelector>(); 42 }; 43 } // namespace TraceStreamer 44 } // namespace SysTuning 45 #endif // RPC_RPC_H 46