• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_selector.h"
22 namespace SysTuning {
23 namespace TraceStreamer {
24 class RpcServer {
25 public:
26     using ResultCallBack = std::function<void(const std::string /* result */)>;
27     bool ParseData(const uint8_t* data, size_t len, ResultCallBack resultCallBack);
28     bool ParseDataOver(const uint8_t* data, size_t len, ResultCallBack resultCallBack);
29     bool SqlOperate(const uint8_t* data, size_t len, ResultCallBack resultCallBack);
30     bool SqlQuery(const uint8_t* data, size_t len, ResultCallBack resultCallBack);
31     bool Reset(const uint8_t* data, size_t len, ResultCallBack resultCallBack);
32 
33     // only for wasm, no callback
34     int WasmSqlQuery(const uint8_t* data, size_t len, uint8_t* out, int outLen);
35 
36 private:
37     std::unique_ptr<TraceStreamerSelector> ts_ = std::make_unique<TraceStreamerSelector>();
38     size_t lenParseData_ = 0;
39 };
40 } // namespace TraceStreamer
41 } // namespace SysTuning
42 #endif // RPC_RPC_H
43