-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpc_msg.h
68 lines (54 loc) · 1.52 KB
/
rpc_msg.h
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
62
63
64
65
66
67
68
/*!
* Copyright (c) 2020 by Contributors
* \file rpc/rpc_msg.h
* \brief Common headers for remote process call (RPC).
*/
#ifndef DGL_RPC_RPC_MSG_H_
#define DGL_RPC_RPC_MSG_H_
#include <dgl/runtime/object.h>
#include <string>
#include <vector>
namespace dgl {
namespace rpc {
/*! \brief RPC message data structure
*
* This structure is exposed to Python and can be used as argument or return
* value in C API.
*/
struct RPCMessage : public runtime::Object {
/*! \brief Service ID */
int32_t service_id;
/*! \brief Sequence number of this message. */
int64_t msg_seq;
/*! \brief Client ID. */
int32_t client_id;
/*! \brief Server ID. */
int32_t server_id;
/*! \brief Payload buffer carried by this request.*/
std::string data;
/*! \brief Extra payloads in the form of tensors.*/
std::vector<runtime::NDArray> tensors;
bool Load(dmlc::Stream* stream) {
stream->Read(&service_id);
stream->Read(&msg_seq);
stream->Read(&client_id);
stream->Read(&server_id);
stream->Read(&data);
stream->Read(&tensors);
return true;
}
void Save(dmlc::Stream* stream) const {
stream->Write(service_id);
stream->Write(msg_seq);
stream->Write(client_id);
stream->Write(server_id);
stream->Write(data);
stream->Write(tensors);
}
static constexpr const char* _type_key = "rpc.RPCMessage";
DGL_DECLARE_OBJECT_TYPE_INFO(RPCMessage, runtime::Object);
};
DGL_DEFINE_OBJECT_REF(RPCMessageRef, RPCMessage);
} // namespace rpc
} // namespace dgl
#endif // DGL_RPC_RPC_MSG_H_