interstice_core/network/
protocol.rs1use interstice_abi::NodeSchema;
2use interstice_abi::{IntersticeValue, Row};
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Serialize, Deserialize)]
6pub enum NetworkPacket {
7 Handshake {
8 node_id: String,
9 address: String,
10 token: String,
11 },
12 Close,
13 ReducerCall {
14 module_name: String,
15 reducer_name: String,
16 input: IntersticeValue,
17 },
18 QueryCall {
19 request_id: String,
20 module_name: String,
21 query_name: String,
22 input: IntersticeValue,
23 },
24 QueryResponse {
25 request_id: String,
26 result: IntersticeValue,
27 },
28 RequestSubscription(RequestSubscription),
29 RequestUnsubscription(RequestSubscription),
30 RequestTableSync {
31 module_name: String,
32 table_name: String,
33 },
34 TableSyncResponse {
35 module_name: String,
36 table_name: String,
37 rows: Vec<Row>,
38 },
39 TableEvent(TableEventInstance),
40 ModuleEvent(ModuleEventInstance),
41 SchemaRequest {
42 request_id: String,
43 node_name: String,
44 },
45 SchemaResponse {
46 request_id: String,
47 schema: NodeSchema,
48 },
49 Error(String),
50}
51
52#[derive(Debug, Serialize, Deserialize, Clone)]
53pub struct RequestSubscription {
54 pub module_name: String,
55 pub table_name: String,
56 pub event: TableEvent,
57}
58
59#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
60pub enum TableEvent {
61 Insert,
62 Update,
63 Delete,
64}
65
66#[derive(Debug, Serialize, Deserialize)]
67pub enum TableEventInstance {
68 TableInsertEvent {
69 module_name: String,
70 table_name: String,
71 inserted_row: Row,
72 },
73 TableUpdateEvent {
74 module_name: String,
75 table_name: String,
76 old_row: Row,
77 new_row: Row,
78 },
79 TableDeleteEvent {
80 module_name: String,
81 table_name: String,
82 deleted_row: Row,
83 },
84}
85
86#[derive(Debug, Serialize, Deserialize)]
87pub enum ModuleEventInstance {
88 Publish { wasm_binary: Vec<u8> },
89 Remove { module_name: String },
90}