| // 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. |
| |
| #pragma once |
| |
| #include <gen_cpp/internal_service.pb.h> |
| |
| #include <atomic> |
| #include <mutex> |
| #include <string> |
| |
| #include "common/status.h" |
| |
| namespace google::protobuf { |
| class Closure; |
| class RpcController; |
| } // namespace google::protobuf |
| |
| namespace doris { |
| |
| class CdcClientMgr { |
| public: |
| CdcClientMgr(); |
| ~CdcClientMgr(); |
| |
| void stop(); |
| |
| // Request CDC client to handle a request |
| void request_cdc_client_impl(const PRequestCdcClientRequest* request, |
| PRequestCdcClientResult* result, google::protobuf::Closure* done); |
| |
| Status send_request_to_cdc_client(const std::string& api, const std::string& params_body, |
| std::string* response); |
| |
| Status start_cdc_client(PRequestCdcClientResult* result); |
| |
| #ifdef BE_TEST |
| // For testing only: get current child PID |
| pid_t get_child_pid() const { return _child_pid.load(); } |
| // For testing only: set child PID directly |
| void set_child_pid_for_test(pid_t pid) { _child_pid.store(pid); } |
| #endif |
| |
| private: |
| std::mutex _start_mutex; |
| std::atomic<pid_t> _child_pid {0}; |
| }; |
| |
| } // namespace doris |