Coverage Report

Created: 2026-03-16 21:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/util/thrift_rpc_helper.h
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
20
#include <gen_cpp/Types_types.h>
21
#include <stdint.h>
22
23
#include <functional>
24
#include <string>
25
26
#include "common/config.h"
27
#include "common/status.h"
28
29
namespace doris {
30
31
class ExecEnv;
32
template <class T>
33
class ClientConnection;
34
35
// this class is a helper for jni call. easy for unit test
36
class ThriftRpcHelper {
37
public:
38
    static void setup(ExecEnv* exec_env);
39
40
    // for default timeout
41
    template <typename T>
42
    static Status rpc(const std::string& ip, const int32_t port,
43
0
                      std::function<void(ClientConnection<T>&)> callback) {
44
0
        return rpc(ip, port, callback, config::thrift_rpc_timeout_ms);
45
0
    }
Unexecuted instantiation: _ZN5doris15ThriftRpcHelper3rpcINS_21FrontendServiceClientEEENS_6StatusERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiSt8functionIFvRNS_16ClientConnectionIT_EEEE
Unexecuted instantiation: _ZN5doris15ThriftRpcHelper3rpcINS_20BackendServiceClientEEENS_6StatusERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiSt8functionIFvRNS_16ClientConnectionIT_EEEE
46
47
    template <typename T>
48
    static Status rpc(std::function<TNetworkAddress()> address_provider,
49
                      std::function<void(ClientConnection<T>&)> callback) {
50
        return rpc(address_provider, callback, config::thrift_rpc_timeout_ms);
51
    }
52
53
    template <typename T>
54
    static Status rpc(const std::string& ip, const int32_t port,
55
                      std::function<void(ClientConnection<T>&)> callback, int timeout_ms);
56
57
    template <typename T>
58
    static Status rpc(std::function<TNetworkAddress()> address_provider,
59
                      std::function<void(ClientConnection<T>&)> callback, int timeout_ms);
60
61
0
    static ExecEnv* get_exec_env() { return _s_exec_env; }
62
63
private:
64
    static ExecEnv* _s_exec_env;
65
};
66
67
} // namespace doris