aboutsummaryrefslogtreecommitdiff
path: root/contrib/native/client/src/clientlib/rpcMessage.hpp
blob: 15487e9ba95c030de5f845c8405ec133d1b31b04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * 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.
 */


#ifndef RPC_MESSAGE_H
#define RPC_MESSAGE_H

#include <ostream>
#include <google/protobuf/message_lite.h>
#include "GeneralRPC.pb.h"

namespace Drill {
namespace rpc {
struct InBoundRpcMessage {
    public:
        exec::rpc::RpcMode m_mode;
        int m_rpc_type;
        int m_coord_id;
        DataBuf m_pbody;
        ByteBuf_t m_dbody;
        bool m_has_mode;
        bool m_has_rpc_type;
        bool has_mode() { return m_has_mode; };
        bool has_rpc_type() { return m_has_rpc_type; };
};

struct OutBoundRpcMessage {
    public:
        exec::rpc::RpcMode m_mode;
        int m_rpc_type;
        int m_coord_id;
        const google::protobuf::MessageLite* m_pbody;
        OutBoundRpcMessage(exec::rpc::RpcMode mode, int rpc_type, int coord_id, const google::protobuf::MessageLite* pbody):
            m_mode(mode), m_rpc_type(rpc_type), m_coord_id(coord_id), m_pbody(pbody) { }
};

std::size_t lengthDecode(const uint8_t* buf, uint32_t& length);

bool decode(const uint8_t* buf, int length, InBoundRpcMessage& msg);

bool encode(DataBuf& buf, const OutBoundRpcMessage& msg);

} // namespace rpc
} // namespace Drill

#endif