├── .gitignore ├── README.md ├── LICENSE ├── 3.0 ├── thrift │ ├── packets.thrift │ └── gen-nodejs │ │ └── packets_types.js ├── protocol-buffer │ └── packets.proto └── PROTOCOL.md ├── 4.0 ├── thrift │ ├── packets.thrift │ └── gen-nodejs │ │ └── packets_types.js ├── protocol-buffer │ └── packets.proto ├── media │ ├── broker-start.svg │ └── broker-stop.svg └── PROTOCOL.md └── 5.0 ├── media ├── broker-start.svg └── broker-stop.svg └── PROTOCOL.md /.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Protocol 2 | Protocol documentation of Moleculer microservices framework 3 | 4 | ## Versions 5 | 6 | ### [5.0](5.0/PROTOCOL.md) 7 | 8 | ### [4.0](4.0/PROTOCOL.md) 9 | 10 | ### [3.0](3.0/PROTOCOL.md) 11 | 12 | # License 13 | Moleculer is available under the [MIT license](https://tldrlegal.com/license/mit-license). 14 | 15 | # Contact 16 | Copyright (c) 2016-2024 MoleculerJS 17 | 18 | [![@moleculerjs](https://img.shields.io/badge/github-moleculer--framework-green.svg)](https://github.com/moleculer-framework) [![@MoleculerJS](https://img.shields.io/badge/twitter-MoleculerJS-blue.svg)](https://twitter.com/MoleculerJS) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Moleculer Framework 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /3.0/thrift/packets.thrift: -------------------------------------------------------------------------------- 1 | 2 | namespace java services.moleculer.serializers.thrift 3 | 4 | struct PacketEvent { 5 | 1: string ver, 6 | 2: string sender, 7 | 3: string event, 8 | 4: optional string data, 9 | 5: list groups, 10 | 6: bool broadcast, 11 | } 12 | 13 | struct PacketRequest { 14 | 1: string ver, 15 | 2: string sender, 16 | 3: string id, 17 | 4: string action, 18 | 5: optional binary params, 19 | 6: string meta, 20 | 7: double timeout, 21 | 8: i32 level, 22 | 9: optional bool metrics, 23 | 10: optional string parentID, 24 | 11: optional string requestID, 25 | 12: optional bool stream, 26 | } 27 | 28 | struct PacketResponse { 29 | 1: string ver, 30 | 2: string sender, 31 | 3: string id, 32 | 4: bool success, 33 | 5: optional binary data, 34 | 6: optional string error, 35 | 7: string meta, 36 | 8: optional bool stream, 37 | } 38 | 39 | struct PacketDiscover { 40 | 1: string ver, 41 | 2: string sender, 42 | } 43 | 44 | struct Client { 45 | 1: string type, 46 | 2: string version, 47 | 3: string langVersion, 48 | } 49 | 50 | struct PacketInfo { 51 | 1: string ver, 52 | 2: string sender, 53 | 3: string services, 54 | 4: string config, 55 | 56 | 5: list ipList, 57 | 6: string hostname, 58 | 7: Client client, 59 | 8: i32 seq, 60 | } 61 | 62 | struct PacketDisconnect { 63 | 1: string ver, 64 | 2: string sender, 65 | } 66 | 67 | struct PacketHeartbeat { 68 | 1: string ver, 69 | 2: string sender, 70 | 3: double cpu, 71 | } 72 | 73 | struct PacketPing { 74 | 1: string ver, 75 | 2: string sender, 76 | 3: i64 time, 77 | } 78 | 79 | struct PacketPong { 80 | 1: string ver, 81 | 2: string sender, 82 | 3: i64 time, 83 | 4: i64 arrived, 84 | } 85 | 86 | struct PacketGossipHello { 87 | 1: string ver, 88 | 2: string sender, 89 | 3: string host, 90 | 4: i32 port, 91 | } 92 | 93 | struct PacketGossipRequest { 94 | 1: string ver, 95 | 2: string sender, 96 | 3: optional string online, 97 | 4: optional string offline, 98 | } 99 | 100 | struct PacketGossipResponse { 101 | 1: string ver, 102 | 2: string sender, 103 | 3: optional string online, 104 | 4: optional string offline, 105 | } 106 | -------------------------------------------------------------------------------- /3.0/protocol-buffer/packets.proto: -------------------------------------------------------------------------------- 1 | // packets.proto 2 | syntax = "proto3"; 3 | package packets; 4 | 5 | message PacketEvent { 6 | string ver = 1; 7 | string sender = 2; 8 | string event = 3; 9 | string data = 4; 10 | repeated string groups = 5; 11 | bool broadcast = 6; 12 | } 13 | 14 | message PacketRequest { 15 | string ver = 1; 16 | string sender = 2; 17 | string id = 3; 18 | string action = 4; 19 | bytes params = 5; 20 | string meta = 6; 21 | double timeout = 7; 22 | int32 level = 8; 23 | bool metrics = 9; 24 | string parentID = 10; 25 | string requestID = 11; 26 | bool stream = 12; 27 | } 28 | 29 | message PacketResponse { 30 | string ver = 1; 31 | string sender = 2; 32 | string id = 3; 33 | bool success = 4; 34 | bytes data = 5; 35 | string error = 6; 36 | string meta = 7; 37 | bool stream = 8; 38 | } 39 | 40 | message PacketDiscover { 41 | string ver = 1; 42 | string sender = 2; 43 | } 44 | 45 | message PacketInfo { 46 | string ver = 1; 47 | string sender = 2; 48 | string services = 3; 49 | string config = 4; 50 | 51 | repeated string ipList = 5; 52 | string hostname = 6; 53 | Client client = 7; 54 | int32 seq = 8; 55 | 56 | message Client { 57 | string type = 1; 58 | string version = 2; 59 | string langVersion = 3; 60 | } 61 | } 62 | 63 | message PacketDisconnect { 64 | string ver = 1; 65 | string sender = 2; 66 | } 67 | 68 | message PacketHeartbeat { 69 | string ver = 1; 70 | string sender = 2; 71 | double cpu = 3; 72 | } 73 | 74 | message PacketPing { 75 | string ver = 1; 76 | string sender = 2; 77 | int64 time = 3; 78 | } 79 | 80 | message PacketPong { 81 | string ver = 1; 82 | string sender = 2; 83 | int64 time = 3; 84 | int64 arrived = 4; 85 | } 86 | 87 | message PacketGossipHello { 88 | string ver = 1; 89 | string sender = 2; 90 | string host = 3; 91 | int32 port = 4; 92 | } 93 | 94 | message PacketGossipRequest { 95 | string ver = 1; 96 | string sender = 2; 97 | string online = 3; 98 | string offline = 4; 99 | } 100 | 101 | message PacketGossipResponse { 102 | string ver = 1; 103 | string sender = 2; 104 | string online = 3; 105 | string offline = 4; 106 | } 107 | -------------------------------------------------------------------------------- /4.0/thrift/packets.thrift: -------------------------------------------------------------------------------- 1 | 2 | namespace java services.moleculer.serializers.thrift 3 | 4 | enum DataType { 5 | DATATYPE_UNDEFINED = 0, 6 | DATATYPE_NULL = 1, 7 | DATATYPE_JSON = 2, 8 | DATATYPE_BUFFER = 3 9 | } 10 | 11 | 12 | struct PacketEvent { 13 | 1: string ver, 14 | 2: string sender, 15 | 3: string id, 16 | 4: string event, 17 | 5: optional binary data, 18 | 6: DataType dataType, 19 | 7: list groups, 20 | 8: bool broadcast, 21 | 9: string meta, 22 | 10: i32 level, 23 | 11: optional bool tracing, 24 | 12: optional string parentID, 25 | 13: optional string requestID, 26 | 14: optional bool stream, 27 | 15: optional i32 seq, 28 | 16: optional string caller, 29 | 17: bool needAck, 30 | } 31 | 32 | struct PacketRequest { 33 | 1: string ver, 34 | 2: string sender, 35 | 3: string id, 36 | 4: string action, 37 | 5: optional binary params, 38 | 6: DataType paramsType, 39 | 7: string meta, 40 | 8: double timeout, 41 | 9: i32 level, 42 | 10: optional bool tracing, 43 | 11: optional string parentID, 44 | 12: optional string requestID, 45 | 13: optional bool stream, 46 | 14: optional i32 seq, 47 | 15: optional string caller, 48 | } 49 | 50 | struct PacketResponse { 51 | 1: string ver, 52 | 2: string sender, 53 | 3: string id, 54 | 4: bool success, 55 | 5: optional binary data, 56 | 6: DataType dataType, 57 | 7: optional string error, 58 | 8: string meta, 59 | 9: optional bool stream, 60 | 10: optional i32 seq, 61 | } 62 | 63 | struct PacketDiscover { 64 | 1: string ver, 65 | 2: string sender, 66 | } 67 | 68 | struct Client { 69 | 1: string type, 70 | 2: string version, 71 | 3: string langVersion, 72 | } 73 | 74 | struct PacketInfo { 75 | 1: string ver, 76 | 2: string sender, 77 | 3: string services, 78 | 4: string config, 79 | 80 | 5: list ipList, 81 | 6: string hostname, 82 | 7: Client client, 83 | 8: i32 seq, 84 | 9: string instanceID, 85 | 10: string metadata, 86 | } 87 | 88 | struct PacketDisconnect { 89 | 1: string ver, 90 | 2: string sender, 91 | } 92 | 93 | struct PacketHeartbeat { 94 | 1: string ver, 95 | 2: string sender, 96 | 3: double cpu, 97 | } 98 | 99 | struct PacketPing { 100 | 1: string ver, 101 | 2: string sender, 102 | 3: i64 time, 103 | 4: string id, 104 | } 105 | 106 | struct PacketPong { 107 | 1: string ver, 108 | 2: string sender, 109 | 3: i64 time, 110 | 4: i64 arrived, 111 | 5: string id, 112 | } 113 | 114 | struct PacketGossipHello { 115 | 1: string ver, 116 | 2: string sender, 117 | 3: string host, 118 | 4: i32 port, 119 | } 120 | 121 | struct PacketGossipRequest { 122 | 1: string ver, 123 | 2: string sender, 124 | 3: optional string online, 125 | 4: optional string offline, 126 | } 127 | 128 | struct PacketGossipResponse { 129 | 1: string ver, 130 | 2: string sender, 131 | 3: optional string online, 132 | 4: optional string offline, 133 | } 134 | -------------------------------------------------------------------------------- /4.0/protocol-buffer/packets.proto: -------------------------------------------------------------------------------- 1 | // packets.proto 2 | syntax = "proto3"; 3 | package packets; 4 | 5 | enum DataType { 6 | DATATYPE_UNDEFINED = 0; 7 | DATATYPE_NULL = 1; 8 | DATATYPE_JSON = 2; 9 | DATATYPE_BUFFER = 3; 10 | } 11 | 12 | message PacketEvent { 13 | string ver = 1; 14 | string sender = 2; 15 | string id = 3; 16 | string event = 4; 17 | bytes data = 5; 18 | DataType dataType = 6; 19 | repeated string groups = 7; 20 | string meta = 9; 21 | bool broadcast = 8; 22 | int32 level = 10; 23 | bool tracing = 11; 24 | string parentID = 12; 25 | string requestID = 13; 26 | bool stream = 14; 27 | int32 seq = 15; 28 | string caller = 16; 29 | bool needAck = 17; 30 | } 31 | 32 | message PacketRequest { 33 | string ver = 1; 34 | string sender = 2; 35 | string id = 3; 36 | string action = 4; 37 | bytes params = 5; 38 | DataType paramsType = 6; 39 | string meta = 7; 40 | double timeout = 8; 41 | int32 level = 9; 42 | bool tracing = 10; 43 | string parentID = 11; 44 | string requestID = 12; 45 | bool stream = 13; 46 | int32 seq = 14; 47 | string caller = 15; 48 | } 49 | 50 | message PacketResponse { 51 | string ver = 1; 52 | string sender = 2; 53 | string id = 3; 54 | bool success = 4; 55 | bytes data = 5; 56 | DataType dataType = 6; 57 | string error = 7; 58 | string meta = 8; 59 | bool stream = 9; 60 | int32 seq = 10; 61 | } 62 | 63 | message PacketDiscover { 64 | string ver = 1; 65 | string sender = 2; 66 | } 67 | 68 | message PacketInfo { 69 | string ver = 1; 70 | string sender = 2; 71 | string services = 3; 72 | string config = 4; 73 | 74 | repeated string ipList = 5; 75 | string hostname = 6; 76 | Client client = 7; 77 | int32 seq = 8; 78 | string instanceID = 9; 79 | string metadata = 10; 80 | 81 | message Client { 82 | string type = 1; 83 | string version = 2; 84 | string langVersion = 3; 85 | } 86 | 87 | } 88 | 89 | message PacketDisconnect { 90 | string ver = 1; 91 | string sender = 2; 92 | } 93 | 94 | message PacketHeartbeat { 95 | string ver = 1; 96 | string sender = 2; 97 | double cpu = 3; 98 | } 99 | 100 | message PacketPing { 101 | string ver = 1; 102 | string sender = 2; 103 | int64 time = 3; 104 | string id = 4; 105 | } 106 | 107 | message PacketPong { 108 | string ver = 1; 109 | string sender = 2; 110 | int64 time = 3; 111 | int64 arrived = 4; 112 | string id = 5; 113 | } 114 | 115 | message PacketGossipHello { 116 | string ver = 1; 117 | string sender = 2; 118 | string host = 3; 119 | int32 port = 4; 120 | } 121 | 122 | message PacketGossipRequest { 123 | string ver = 1; 124 | string sender = 2; 125 | string online = 3; 126 | string offline = 4; 127 | } 128 | 129 | message PacketGossipResponse { 130 | string ver = 1; 131 | string sender = 2; 132 | string online = 3; 133 | string offline = 4; 134 | } 135 | -------------------------------------------------------------------------------- /4.0/media/broker-start.svg: -------------------------------------------------------------------------------- 1 | 2 |
Start
Start
Call `starting` handlers in middlewares
Call `<font face="Lucida Console">starting</font>` handlers in middlewares
Transporter connect
Transporter connect
Start services
(call `started` in services)
[Not supported by viewer]
Emit `$broker.started`
Emit `<font face="Lucida Console">$broker.started</font>`
Transporter publishes local services
Transporter publishes local services
Call `started` handlers in middlewares
Call `<font face="Lucida Console">started</font>` handlers in middlewares
Call `started` handler in broker options
Call `<font face="Lucida Console">started</font>` handler in broker options
End
End
-------------------------------------------------------------------------------- /5.0/media/broker-start.svg: -------------------------------------------------------------------------------- 1 | 2 |
Start
Start
Call `starting` handlers in middlewares
Call `<font face="Lucida Console">starting</font>` handlers in middlewares
Transporter connect
Transporter connect
Start services
(call `started` in services)
[Not supported by viewer]
Emit `$broker.started`
Emit `<font face="Lucida Console">$broker.started</font>`
Transporter publishes local services
Transporter publishes local services
Call `started` handlers in middlewares
Call `<font face="Lucida Console">started</font>` handlers in middlewares
Call `started` handler in broker options
Call `<font face="Lucida Console">started</font>` handler in broker options
End
End
-------------------------------------------------------------------------------- /3.0/PROTOCOL.md: -------------------------------------------------------------------------------- 1 | # Protocol 3.0 (rev. 2) 2 | 3 | This documentation describes the communication protocol between Moleculer nodes. 4 | 5 | **Variables in topic names:** 6 | 7 | - `` - Namespace from broker options 8 | - `` - Target nodeID 9 | - `` - Action name. E.g.: `posts.find` 10 | - `` - Event group name. E.g.: `users` 11 | - `` - Event name. E.g.: `user.created` 12 | 13 | ## Subscriptions 14 | 15 | After the client is connected to the message broker (NATS, Redis, MQTT), it subscribes to the following topics: 16 | 17 | | Type | Topic name | 18 | | -------------------- | ----------------------- | 19 | | Event | `MOL.EVENT.` | 20 | | Event (balanced) | `MOL.EVENTB.` | 21 | | Request | `MOL.REQ.` | 22 | | Request (balanced) | `MOL.REQB.` | 23 | | Response | `MOL.RES.` | 24 | | Discover | `MOL.DISCOVER` | 25 | | Discover (targetted) | `MOL.DISCOVER.` | 26 | | Info | `MOL.INFO` | 27 | | Info (targetted) | `MOL.INFO.` | 28 | | Heartbeat | `MOL.HEARTBEAT` | 29 | | Ping | `MOL.PING` | 30 | | Ping (targetted) | `MOL.PING.` | 31 | | Pong | `MOL.PONG.` | 32 | | Disconnect | `MOL.DISCONNECT` | 33 | 34 | > If `namespace` is defined, the topic prefix is `MOL-namespace` instead of `MOL`. For example: `MOL-dev.EVENT` if the namespace is `dev`. 35 | 36 | ## Discovering 37 | 38 | After subscriptions, the client broadcasts a `DISCOVER` packet. In response to this, all connected nodes send back `INFO` packet to the sender node. From these responses, the client builds its own service registry. At last, the client broadcasts own INFO packet to all other nodes. 39 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_discover.png) 40 | 41 | ## Heartbeat 42 | 43 | The client has to broadcast `HEARTBEAT` packets periodically. The period value comes from broker options (`heartbeatInterval`). The default value is 5 secs. 44 | If the client does not receive `HEARTBEAT` for `heartbeatTimeout` seconds from a node, marks it broken and doesn't route requests to this node. 45 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_heartbeat.png) 46 | 47 | ## Request-reply 48 | 49 | When you call the `broker.call` method, the broker sends a `REQUEST` packet to the targetted node. It processes the request and sends back a `RESPONSE` packet to the requester node. 50 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_request.png) 51 | 52 | ## Event 53 | 54 | When you call the `broker.emit` method, the broker sends an `EVENT` packet to the subscriber nodes. The broker groups & balances the subscribers, so only one instance per service receives the event. If you call the `broker.broadcast` method, the broker sends an `ĘVENT` packet to all subscriber nodes. It doesn't group & balance the subscribers. 55 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_event.png) 56 | 57 | ## Ping-pong 58 | 59 | When you call the `broker.ping` method, the broker sends a `PING` packet to the targetted node. If node is not defined, it sends to all nodes. If the client receives the `PING` packet, sends back a `PONG` response packet. If it receives, broker broadcasts a local `$node.pong` event to the local services. 60 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_pong.png) 61 | 62 | ## Disconnect 63 | 64 | When a node is stopping, it broadcasts a `DISCONNECT` packet to all nodes. 65 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_disconnect.png) 66 | 67 | ## Packets 68 | 69 | ### `DISCOVER` 70 | 71 | **Topic name:** 72 | 73 | - `MOL.DISCOVER` (if broadcasts) 74 | - `MOL.DISCOVER.node-1` (if sent only to `node-1`) 75 | - `MOL-dev.DISCOVER` (if namespace is `dev`) 76 | 77 | **Fields:** 78 | 79 | | Field | Type | Required | Description | 80 | | -------- | -------- | -------- | --------------------------------- | 81 | | `ver` | `string` | ✔ | Protocol version. Current: `'3'`. | 82 | | `sender` | `string` | ✔ | Sender nodeID. | 83 | 84 | ### `INFO` 85 | 86 | **Topic name:** 87 | 88 | - `MOL.INFO` (if broadcasts) 89 | - `MOL.INFO.node-1` (if sent only to `node-1`) 90 | - `MOL-dev.INFO` (if namespace is `dev`) 91 | 92 | **Fields:** 93 | 94 | | Field | Type | Required | Description | 95 | | -------------------- | ---------- | -------- | ----------------------------------------------------- | 96 | | `ver` | `string` | ✔ | Protocol version. Current: `'3'`. | 97 | | `sender` | `string` | ✔ | Sender nodeID. | 98 | | `services` | `object` | ✔ | Services list. (\*) | 99 | | `config` | `object` | ✔ | Client configuration. (\*) | 100 | | `ipList` | `[string]` | ✔ | IP address list of node | 101 | | `hostname` | `string` | ✔ | Hostname of node | 102 | | `client` | `object` | ✔ | Client information | 103 | | `client.type` | `string` | ✔ | Type of client implementation(`nodejs`, `java`, `go`) | 104 | | `client.version` | `string` | ✔ | Client (Moleculer) version | 105 | | `client.langVersion` | `string` | ✔ | NodeJS/Java/Go version | 106 | 107 | > (\*) In case of `ProtoBuf`, `Avro` or any other schema-based serializer, the field value is encoded to JSON string. 108 | 109 | ### `HEARTBEAT` 110 | 111 | **Topic name:** 112 | 113 | - `MOL.HEARTBEAT` 114 | - `MOL-dev.HEARTBEAT` (if namespace is `dev`) 115 | 116 | **Fields:** 117 | 118 | | Field | Type | Required | Description | 119 | | -------- | -------- | -------- | ------------------------------------- | 120 | | `ver` | `string` | ✔ | Protocol version. Current: `'3'`. | 121 | | `sender` | `string` | ✔ | Sender nodeID. | 122 | | `cpu` | `double` | ✔ | Current CPU utilization (percentage). | 123 | 124 | ### `REQUEST` 125 | 126 | **Topic name:** 127 | 128 | - `MOL.REQ.node-2` 129 | - `MOL.REQB.` (if built-in balancer is disabled) 130 | - `MOL-dev.REQ.node-2` (if namespace is `dev`) 131 | 132 | **Fields:** 133 | 134 | | Field | Type | Required | Description | 135 | | ----------- | --------- | -------- | ---------------------------------------------- | 136 | | `ver` | `string` | ✔ | Protocol version. Current: `'3'`. | 137 | | `sender` | `string` | ✔ | Sender nodeID. | 138 | | `id` | `string` | ✔ | Context ID. | 139 | | `action` | `string` | ✔ | Action name. E.g.: `posts.find` | 140 | | `params` | `object` | ✔ | `ctx.params` object. (\*) | 141 | | `meta` | `object` | ✔ | `ctx.meta` object. (\*) | 142 | | `timeout` | `double` | ✔ | Request timeout (distributed) in milliseconds. | 143 | | `level` | `int32` | ✔ | Level of request. | 144 | | `metrics` | `boolean` | ✔ | Need to send metrics events. | 145 | | `parentID` | `string` | | Parent context ID. | 146 | | `requestID` | `string` | | Request ID from `ctx.requestID`. | 147 | | `stream` | `boolean` | ✔ | Stream request. | 148 | 149 | > (\*) In case of `ProtoBuf`, `Avro` or any other schema-based serializer, the field value is encoded to JSON string. 150 | 151 | ### `RESPONSE` 152 | 153 | **Topic name:** 154 | 155 | - `MOL.RES.node-1` 156 | - `MOL-dev.RES.node-1` (if namespace is `dev`) 157 | 158 | **Fields:** 159 | 160 | | Field | Type | Required | Description | 161 | | --------- | --------- | -------- | --------------------------------- | 162 | | `ver` | `string` | ✔ | Protocol version. Current: `'3'`. | 163 | | `sender` | `string` | ✔ | Sender nodeID. | 164 | | `id` | `string` | ✔ | Context ID (from `REQUEST`). | 165 | | `success` | `boolean` | ✔ | Is it a success response? | 166 | | `data` | `object` | | Response data if success. (\*) | 167 | | `error` | `object` | | Error object if not success. (\*) | 168 | | `meta` | `object` | ✔ | `ctx.meta` object. (\*) | 169 | | `stream` | `boolean` | ✔ | Stream request. | 170 | 171 | > (\*) In case of `ProtoBuf`, `Avro` or any other schema-based serializer, the field value is encoded to JSON string. 172 | 173 | ### `EVENT` 174 | 175 | **Topic name:** 176 | 177 | - `MOL.EVENT.node-1` 178 | - `MOL.EVENTB..` (if built-in balancer is disabled) 179 | - `MOL-dev.EVENT.node-1` (if namespace is `dev`) 180 | 181 | **Fields:** 182 | 183 | | Field | Type | Required | Description | 184 | | ----------- | --------------- | -------- | --------------------------------- | 185 | | `ver` | `string` | ✔ | Protocol version. Current: `'3'`. | 186 | | `sender` | `string` | ✔ | Sender nodeID. | 187 | | `event` | `string` | ✔ | Event name. E.g.: `users.created` | 188 | | `data` | `object` | | Event payload. (\*) | 189 | | `groups` | `Array` | | Groups for balanced events. | 190 | | `broadcast` | `boolean` | ✔ | Broadcast event | 191 | 192 | > (\*) In case of `ProtoBuf`, `Avro` or any other schema-based serializer, the field value is encoded to JSON string. 193 | 194 | ### `PING` 195 | 196 | **Topic name:** 197 | 198 | - `MOL.PING` (if broadcasts) 199 | - `MOL.PING.node-1` (if sent only to `node-1`) 200 | - `MOL-dev.PING` (if namespace is `dev`) 201 | 202 | **Fields:** 203 | 204 | | Field | Type | Required | Description | 205 | | -------- | -------- | -------- | --------------------------------- | 206 | | `ver` | `string` | ✔ | Protocol version. Current: `'3'`. | 207 | | `sender` | `string` | ✔ | Sender nodeID. | 208 | | `time` | `int64` | ✔ | Time of sent. (\*) | 209 | 210 | > (\*) The number of milliseconds between 1 January 1970 00:00:00 UTC and the given date. 211 | 212 | ### `PONG` 213 | 214 | **Topic name:** 215 | 216 | - `MOL.PONG.node-1` 217 | - `MOL-dev.PONG` (if namespace is `dev`) 218 | 219 | **Fields:** 220 | 221 | | Field | Type | Required | Description | 222 | | --------- | -------- | -------- | --------------------------------- | 223 | | `ver` | `string` | ✔ | Protocol version. Current: `'3'`. | 224 | | `sender` | `string` | ✔ | Sender nodeID. | 225 | | `time` | `int64` | ✔ | Timestamp of sent. (\*) | 226 | | `arrived` | `int64` | ✔ | Timestamp of arrived. (\*) | 227 | 228 | > (\*) The number of milliseconds between 1 January 1970 00:00:00 UTC and the given date. 229 | 230 | ### `DISCONNECT` 231 | 232 | **Topic name:** 233 | 234 | - `MOL.DISCONNECT` 235 | - `MOL-dev.DISCONNECT` (if namespace is `dev`) 236 | 237 | **Fields:** 238 | 239 | | Field | Type | Required | Description | 240 | | -------- | -------- | -------- | --------------------------------- | 241 | | `ver` | `string` | ✔ | Protocol version. Current: `'3'`. | 242 | | `sender` | `string` | ✔ | Sender nodeID. | 243 | -------------------------------------------------------------------------------- /4.0/media/broker-stop.svg: -------------------------------------------------------------------------------- 1 | 2 |
Start
Start
Call `stopping` handlers in middlewares
Call `<font face="Lucida Console">stopping</font>` handlers in middlewares
Transporter disconnect
Transporter disconnect
Cacher disconnect
Cacher disconnect
Stop services
(call `stopped` in services)
[Not supported by viewer]
Emit `$broker.stopped`
Emit `<font face="Lucida Console">$broker.stopped</font>`
Call `stopped` handlers in middlewares
Call `<font face="Lucida Console">stopped</font>` handlers in middlewares
Call `stopped` handler in broker options
Call `<font face="Lucida Console">stopped</font>` handler in broker options
End
End
Transporter unpublish local services
Transporter unpublish local services
-------------------------------------------------------------------------------- /5.0/media/broker-stop.svg: -------------------------------------------------------------------------------- 1 | 2 |
Start
Start
Call `stopping` handlers in middlewares
Call `<font face="Lucida Console">stopping</font>` handlers in middlewares
Transporter disconnect
Transporter disconnect
Cacher disconnect
Cacher disconnect
Stop services
(call `stopped` in services)
[Not supported by viewer]
Emit `$broker.stopped`
Emit `<font face="Lucida Console">$broker.stopped</font>`
Call `stopped` handlers in middlewares
Call `<font face="Lucida Console">stopped</font>` handlers in middlewares
Call `stopped` handler in broker options
Call `<font face="Lucida Console">stopped</font>` handler in broker options
End
End
Transporter unpublish local services
Transporter unpublish local services
-------------------------------------------------------------------------------- /5.0/PROTOCOL.md: -------------------------------------------------------------------------------- 1 | # Protocol 5.0 (rev. 1) 2 | 3 | This protocol is used to communicate between the Moleculer nodes. 4 | 5 | ## Concept 6 | 7 | ### Subscriptions 8 | 9 | After the client is connected to the message broker (NATS, Redis, MQTT), it subscribes to the following topics: 10 | 11 | | Type | Topic name | 12 | | ------------------- | ----------------------- | 13 | | Event | `MOL.EVENT.` | 14 | | Event (balanced) | `MOL.EVENTB.` | 15 | | Request | `MOL.REQ.` | 16 | | Request (balanced) | `MOL.REQB.` | 17 | | Response | `MOL.RES.` | 18 | | Discover | `MOL.DISCOVER` | 19 | | Discover (targeted) | `MOL.DISCOVER.` | 20 | | Info | `MOL.INFO` | 21 | | Info (targeted) | `MOL.INFO.` | 22 | | Heartbeat | `MOL.HEARTBEAT` | 23 | | Ping | `MOL.PING` | 24 | | Ping (targeted) | `MOL.PING.` | 25 | | Pong | `MOL.PONG.` | 26 | | Disconnect | `MOL.DISCONNECT` | 27 | 28 | > If `namespace` is defined, the topic prefix is `MOL-` instead of `MOL`. E.g.: `MOL-dev.EVENT` when the namespace is `dev`. 29 | 30 | **Variables in topic names:** 31 | 32 | - `` - Namespace from broker options 33 | - `` - Target nodeID 34 | - `` - Action name. E.g.: `posts.find` 35 | - `` - Event group name. E.g.: `users` 36 | - `` - Event name. E.g.: `user.created` 37 | 38 | ### Discovering 39 | 40 | After subscribing, the transporter broadcasts a `DISCOVER` packet. In response to this, all connected nodes send back `INFO` packet to the sender node. From these responses, the client builds its own service registry. At last, the client broadcasts own INFO packet to all other nodes. 41 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_discover.png) 42 | 43 | ### Heartbeat 44 | 45 | The client has to broadcast `HEARTBEAT` packets periodically. The period value comes from broker options (`heartbeatInterval`). The default value is 5 secs. 46 | If the client does not receive `HEARTBEAT` for `heartbeatTimeout` seconds from a node, marks it broken and doesn't route requests to this node. 47 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_heartbeat.png) 48 | 49 | ### Request-reply 50 | 51 | When you call the `broker.call` method, the broker sends a `REQUEST` packet to the targeted node. It processes the request and sends back a `RESPONSE` packet to the requester node. 52 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_request.png) 53 | 54 | ### Event 55 | 56 | When you call the `broker.emit` method, the broker sends an `EVENT` packet to the subscriber nodes. The broker groups & balances the subscribers, so only one instance per service receives the event. If you call the `broker.broadcast` method, the broker sends an `ĘVENT` packet to all subscriber nodes. It doesn't balance the subscribers. 57 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_event.png) 58 | 59 | ### Ping-pong 60 | 61 | When you call the `broker.ping` method, the broker sends a `PING` packet to the targeted node. If node is not defined, it sends to all nodes. If the client receives the `PING` packet, sends back a `PONG` response packet. If it receives, broker broadcasts a local `$node.pong` event to the local services. 62 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_pong.png) 63 | 64 | ### Disconnect 65 | 66 | When a node is stopping, it broadcasts a `DISCONNECT` packet to all nodes. 67 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_disconnect.png) 68 | 69 | ## Protocol messages 70 | 71 | ### `DISCOVER` 72 | 73 | When the transporter established the connection with the message broker, it broadcasts a `DISCOVER` message to all other nodes. 74 | 75 | **Topic name:** 76 | 77 | - `MOL.DISCOVER` (if broadcasts) 78 | - `MOL.DISCOVER.node-1` (if sent only to `node-1`) 79 | - `MOL-dev.DISCOVER` (if namespace is `dev`) 80 | 81 | **Fields:** 82 | 83 | | Field | Type | Required | Description | 84 | | -------- | -------- | -------- | ----------------- | 85 | | `ver` | `string` | ✔ | Protocol version. | 86 | | `sender` | `string` | ✔ | Sender nodeID. | 87 | 88 | **Example with JSON serializer** 89 | 90 | ```json 91 | { 92 | "ver": "5", 93 | "sender": "node-100" 94 | } 95 | ``` 96 | 97 | ### `INFO` 98 | 99 | When the node receives an `INFO` packet, it sends an `INFO` packet which contains all mandatory information about the nodes and the loaded services. 100 | 101 | **Topic name:** 102 | 103 | - `MOL.INFO` (if broadcasts) 104 | - `MOL.INFO.node-1` (if sent only to `node-1`) 105 | - `MOL-dev.INFO` (if namespace is `dev`) 106 | 107 | **Fields:** 108 | 109 | | Field | Type | Required | Description | 110 | | -------------------- | ---------- | -------- | ----------------------------------------------------- | 111 | | `ver` | `string` | ✔ | Protocol version. | 112 | | `sender` | `string` | ✔ | Sender nodeID. | 113 | | `services` | `object` | ✔ | Services list. (\*) | 114 | | `config` | `object` | ✔ | Client configuration. (\*) | 115 | | `instanceID` | `string` | ✔ | Instance ID | 116 | | `ipList` | `[string]` | ✔ | IP address list of node | 117 | | `hostname` | `string` | ✔ | Hostname of node | 118 | | `client` | `object` | ✔ | Client information | 119 | | `client.type` | `string` | ✔ | Type of client implementation(`nodejs`, `java`, `go`) | 120 | | `client.version` | `string` | ✔ | Client (Moleculer) version | 121 | | `client.langVersion` | `string` | ✔ | NodeJS/Java/Go version | 122 | | `metadata` | `object` | ✔ | Node-specific metadata. (\*) | 123 | 124 | > (\*) In case of schema-based serializers, the field value is encoded to JSON string. 125 | 126 | **Example with JSON serializer** 127 | 128 | ```json 129 | { 130 | "services": [ 131 | { 132 | "name": "$node", 133 | "settings": {}, 134 | "metadata": {}, 135 | "actions": [], 136 | "events": {} 137 | }, 138 | { 139 | "name": "greeter", 140 | "settings": {}, 141 | "metadata": {}, 142 | "actions": [], 143 | "events": {} 144 | } 145 | ], 146 | "ipList": ["10.35.0.34"], 147 | "hostname": "moleculer-server", 148 | "client": { 149 | "type": "nodejs", 150 | "version": "0.14.0-beta3", 151 | "langVersion": "v12.10.0" 152 | }, 153 | "config": {}, 154 | "instanceID": "ee21e97d-9fd0-4d7e-a303-70b1605f477f", 155 | "metadata": {}, 156 | "seq": 2, 157 | "ver": "5", 158 | "sender": "nodeID-1" 159 | } 160 | ``` 161 | 162 | ### `HEARTBEAT` 163 | 164 | **Topic name:** 165 | 166 | - `MOL.HEARTBEAT` 167 | - `MOL-dev.HEARTBEAT` (if namespace is `dev`) 168 | 169 | **Fields:** 170 | 171 | | Field | Type | Required | Description | 172 | | -------- | -------- | -------- | ------------------------------------- | 173 | | `ver` | `string` | ✔ | Protocol version. | 174 | | `sender` | `string` | ✔ | Sender nodeID. | 175 | | `cpu` | `double` | ✔ | Current CPU utilization (percentage). | 176 | 177 | **Example with JSON serializer** 178 | 179 | ```json 180 | { 181 | "ver": "5", 182 | "sender": "node-100", 183 | "cpu": 13.5 184 | } 185 | ``` 186 | 187 | ### `REQUEST` 188 | 189 | **Topic name:** 190 | 191 | - `MOL.REQ.node-2` 192 | - `MOL.REQB.` (if built-in balancer is disabled) 193 | - `MOL-dev.REQ.node-2` (if namespace is `dev`) 194 | 195 | **Fields:** 196 | 197 | | Field | Type | Required | Description | 198 | | ------------ | --------- | -------- | ---------------------------------------------- | 199 | | `ver` | `string` | ✔ | Protocol version. | 200 | | `sender` | `string` | ✔ | Sender nodeID. | 201 | | `id` | `string` | ✔ | Context ID. | 202 | | `action` | `string` | ✔ | Action name. E.g.: `posts.find` | 203 | | `params` | `object` | | `ctx.params` object. | 204 | | `meta` | `object` | ✔ | `ctx.meta` object. | 205 | | `headers` | `object` | | `headers` in calling options. | 206 | | `timeout` | `double` | ✔ | Request timeout (distributed) in milliseconds. | 207 | | `level` | `int32` | ✔ | Level of request. | 208 | | `tracing` | `boolean` | ✔ | Need to send tracing events. | 209 | | `parentID` | `string` | | Parent context ID. | 210 | | `requestID` | `string` | | Request ID from `ctx.requestID`. | 211 | | `caller` | `string` | | Action name of the caller. | 212 | | `stream` | `boolean` | ✔ | Stream request. | 213 | | `seq` | `int32` | | Stream sequence number. | 214 | 215 | **Example with JSON serializer** 216 | 217 | ```json 218 | { 219 | "id": "41238213-da6b-4313-9909-e6edd0e40a96", 220 | "action": "greeter.hello", 221 | "params": {}, 222 | "meta": {}, 223 | "headers": {}, 224 | "timeout": 10000, 225 | "level": 1, 226 | "tracing": null, 227 | "parentID": null, 228 | "requestID": "41238213-da6b-4313-9909-e6edd0e40a96", 229 | "caller": null, 230 | "stream": false, 231 | "ver": "5", 232 | "sender": "nodeID-1" 233 | } 234 | ``` 235 | 236 | ### `RESPONSE` 237 | 238 | **Topic name:** 239 | 240 | - `MOL.RES.node-1` 241 | - `MOL-dev.RES.node-1` (if namespace is `dev`) 242 | 243 | **Fields:** 244 | 245 | | Field | Type | Required | Description | 246 | | ---------- | --------- | -------- | ----------------------------------- | 247 | | `ver` | `string` | ✔ | Protocol version. | 248 | | `sender` | `string` | ✔ | Sender nodeID. | 249 | | `id` | `string` | ✔ | Context ID (from `REQUEST`). | 250 | | `success` | `boolean` | ✔ | Is it a success response? | 251 | | `data` | `object` | | Response data if success. | 252 | | `error` | `object` | | Error object if not success. | 253 | | `meta` | `object` | ✔ | `ctx.meta` object. | 254 | | `headers` | `object` | | `ctx.responseHeaders` object | 255 | | `stream` | `boolean` | ✔ | Stream request. | 256 | | `seq` | `int32` | | Stream sequence number. | 257 | 258 | **Example with JSON serializer** 259 | 260 | ```json 261 | { 262 | "id": "a4dd3ae5-2eff-4924-94bc-4acb8ac034aa", 263 | "meta": {}, 264 | "headers": {}, 265 | "success": true, 266 | "data": { 267 | "message": "Hello Moleculer" 268 | }, 269 | "ver": "5", 270 | "sender": "nodeID-2" 271 | } 272 | ``` 273 | 274 | ### `EVENT` 275 | 276 | **Topic name:** 277 | 278 | - `MOL.EVENT.node-1` 279 | - `MOL.EVENTB..` (if built-in balancer is disabled) 280 | - `MOL-dev.EVENT.node-1` (if namespace is `dev`) 281 | 282 | **Fields:** 283 | 284 | | Field | Type | Required | Description | 285 | | ----------- | --------------- | -------- | ----------------------------------- | 286 | | `ver` | `string` | ✔ | Protocol version. | 287 | | `sender` | `string` | ✔ | Sender nodeID. | 288 | | `id` | `string` | ✔ | Context ID. | 289 | | `event` | `string` | ✔ | Event name. E.g.: `users.created` | 290 | | `data` | `object` | | Event payload. | 291 | | `meta` | `object` | ✔ | `ctx.meta` object. | 292 | | `headers` | `object` | | `headers` in event options | 293 | | `level` | `int32` | ✔ | Level of event. | 294 | | `tracing` | `boolean` | ✔ | Need to send tracing events. | 295 | | `parentID` | `string` | | Parent context ID. | 296 | | `requestID` | `string` | | Request ID from `ctx.requestID`. | 297 | | `caller` | `string` | | Action/Event name of the caller. | 298 | | `stream` | `boolean` | ✔ | Stream request. | 299 | | `seq` | `int32` | | Stream sequence number. | 300 | | `groups` | `Array` | | Groups for balanced events. | 301 | | `broadcast` | `boolean` | ✔ | Broadcast event | 302 | 303 | **Example with JSON serializer** 304 | 305 | ```json 306 | { 307 | "id": "e102630b-c702-4ff9-a0a1-52428395d57a", 308 | "event": "some.test", 309 | "data": { 310 | "name": "John" 311 | }, 312 | "groups": ["greeter"], 313 | "broadcast": false, 314 | "meta": {}, 315 | "headers": {}, 316 | "level": 1, 317 | "tracing": null, 318 | "parentID": null, 319 | "requestID": "e102630b-c702-4ff9-a0a1-52428395d57a", 320 | "caller": null, 321 | "needAck": null, 322 | "ver": "5", 323 | "sender": "nodeID-1" 324 | } 325 | ``` 326 | 327 | ### `EVENTACK` 328 | 329 | **_Not implemented yet._** 330 | 331 | **Topic name:** 332 | 333 | - `MOL.EVENTACK.node-1` 334 | - `MOL-dev.EVENTACK` (if namespace is `dev`) 335 | 336 | **Fields:** 337 | 338 | | Field | Type | Required | Description | 339 | | --------- | --------- | -------- | --------------------------------- | 340 | | `ver` | `string` | ✔ | Protocol version. | 341 | | `sender` | `string` | ✔ | Sender nodeID. | 342 | | `id` | `string` | ✔ | Event Context ID. | 343 | | `success` | `boolean` | ✔ | Is it successful? | 344 | | `group` | `string` | | Group of event handler. | 345 | | `error` | `object` | | Error object if not success. (\*) | 346 | 347 | > (\*) In case of schema-based serializers, the field value is encoded to JSON string. 348 | 349 | **Example with JSON serializer** 350 | 351 | ```json 352 | { 353 | "ver": "5", 354 | "sender": "node-100" 355 | } 356 | ``` 357 | 358 | !!TODO!! 359 | 360 | ### `PING` 361 | 362 | **Topic name:** 363 | 364 | - `MOL.PING` (if broadcasts) 365 | - `MOL.PING.node-1` (if sent only to `node-1`) 366 | - `MOL-dev.PING` (if namespace is `dev`) 367 | 368 | **Fields:** 369 | 370 | | Field | Type | Required | Description | 371 | | -------- | -------- | -------- | ------------------ | 372 | | `ver` | `string` | ✔ | Protocol version. | 373 | | `sender` | `string` | ✔ | Sender nodeID. | 374 | | `id` | `string` | ✔ | Message ID. | 375 | | `time` | `int64` | ✔ | Time of sent. (\*) | 376 | 377 | > (\*) The number of milliseconds between 1 January 1970 00:00:00 UTC and the given date. 378 | 379 | **Example with JSON serializer** 380 | 381 | ```json 382 | { 383 | "time": 1567677050576, 384 | "id": "3e09738f-cedf-4985-85fe-344860c06cfd", 385 | "ver": "5", 386 | "sender": "nodeID-2" 387 | } 388 | ``` 389 | 390 | ### `PONG` 391 | 392 | **Topic name:** 393 | 394 | - `MOL.PONG.node-1` 395 | - `MOL-dev.PONG` (if namespace is `dev`) 396 | 397 | **Fields:** 398 | 399 | | Field | Type | Required | Description | 400 | | --------- | -------- | -------- | -------------------------- | 401 | | `ver` | `string` | ✔ | Protocol version. | 402 | | `sender` | `string` | ✔ | Sender nodeID. | 403 | | `id` | `string` | ✔ | Message ID. | 404 | | `time` | `int64` | ✔ | Timestamp of sent. (\*) | 405 | | `arrived` | `int64` | ✔ | Timestamp of arrived. (\*) | 406 | 407 | > (\*) The number of milliseconds between 1 January 1970 00:00:00 UTC and the given date. 408 | 409 | **Example with JSON serializer** 410 | 411 | ```json 412 | { 413 | "time": 1567677050576, 414 | "id": "3e09738f-cedf-4985-85fe-344860c06cfd", 415 | "arrived": 1567677050577, 416 | "ver": "5", 417 | "sender": "nodeID-1" 418 | } 419 | ``` 420 | 421 | ### `DISCONNECT` 422 | 423 | **Topic name:** 424 | 425 | - `MOL.DISCONNECT` 426 | - `MOL-dev.DISCONNECT` (if namespace is `dev`) 427 | 428 | **Fields:** 429 | 430 | | Field | Type | Required | Description | 431 | | -------- | -------- | -------- | ----------------- | 432 | | `ver` | `string` | ✔ | Protocol version. | 433 | | `sender` | `string` | ✔ | Sender nodeID. | 434 | 435 | **Example with JSON serializer** 436 | 437 | ```json 438 | { 439 | "ver": "5", 440 | "sender": "node-100" 441 | } 442 | ``` 443 | 444 | ## Graceful starting & stopping 445 | 446 | ### Start 447 | 448 | The broker starts by establishing connection with the `transporter` (e.g., NATS server, MQTT broker). After successfully establishing the connection, it starts all services, i.e., calls service `started` handlers. Once all services have started successfully, broker publishes the local service list to remote nodes. Hence remote nodes will send requests only after all local service have started properly. 449 | 450 | **Start lifecycle sequence** 451 | 452 | ![image](media/broker-start.svg) 453 | 454 | ### Stop 455 | 456 | When broker is stopping, it starts by publishing an empty service list to all remote nodes. This is done to inform all remote nodes that the node and it's service will be shut down. Next, broker starts stopping all local services. After that, the transporter disconnects. 457 | 458 | **Stop lifecycle sequence** 459 | 460 | ![image](media/broker-stop.svg) 461 | 462 | ## Streams 463 | 464 | While transferring streams, sequence number (`seq`) field is used to keep track of the chunks and their order. This is especially important in "multi-threaded systems" that can shuffle the packets before sending them. If packets arrive unordered they are stored in a pool until previous chucks arrive. 465 | > The `seq = 0` is the first initial package and it has `params`, `headers` and `meta` properties. This package doesn't contain stream data. 466 | 467 | ## Disabled built-in balancer mode 468 | 469 | When built-in load balancing mechanisms are disabled, the balancing is done by the brokers (e.g., NATS, RabbitMQ). This means that there are no local calls in actions and events. All requests are transferred to transporter that will be responsible for choosing the destination of the request and delivery of the message. 470 | 471 | ## Changes from version `4` 472 | 473 | Removed schema-based serializers (ProtoBuf, Avro, Thrift) 474 | 475 | **REQUEST** 476 | - removed `dataType: enum` property 477 | - new `headers` property 478 | 479 | **RESPONSE** 480 | - removed `dataType: enum` property 481 | - new `headers` property 482 | 483 | **EVENT** 484 | - removed `dataType: enum` property 485 | - new `headers` property 486 | -------------------------------------------------------------------------------- /4.0/PROTOCOL.md: -------------------------------------------------------------------------------- 1 | # Protocol 4.0 (rev. 1) 2 | 3 | This protocol is used to communicate between the Moleculer nodes. 4 | 5 | ## Concept 6 | 7 | ### Subscriptions 8 | 9 | After the client is connected to the message broker (NATS, Redis, MQTT), it subscribes to the following topics: 10 | 11 | | Type | Topic name | 12 | | ------------------- | ----------------------- | 13 | | Event | `MOL.EVENT.` | 14 | | Event (balanced) | `MOL.EVENTB.` | 15 | | Request | `MOL.REQ.` | 16 | | Request (balanced) | `MOL.REQB.` | 17 | | Response | `MOL.RES.` | 18 | | Discover | `MOL.DISCOVER` | 19 | | Discover (targeted) | `MOL.DISCOVER.` | 20 | | Info | `MOL.INFO` | 21 | | Info (targeted) | `MOL.INFO.` | 22 | | Heartbeat | `MOL.HEARTBEAT` | 23 | | Ping | `MOL.PING` | 24 | | Ping (targeted) | `MOL.PING.` | 25 | | Pong | `MOL.PONG.` | 26 | | Disconnect | `MOL.DISCONNECT` | 27 | 28 | > If `namespace` is defined, the topic prefix is `MOL-` instead of `MOL`. E.g.: `MOL-dev.EVENT` when the namespace is `dev`. 29 | 30 | **Variables in topic names:** 31 | 32 | - `` - Namespace from broker options 33 | - `` - Target nodeID 34 | - `` - Action name. E.g.: `posts.find` 35 | - `` - Event group name. E.g.: `users` 36 | - `` - Event name. E.g.: `user.created` 37 | 38 | ### Discovering 39 | 40 | After subscribing, the transporter broadcasts a `DISCOVER` packet. In response to this, all connected nodes send back `INFO` packet to the sender node. From these responses, the client builds its own service registry. At last, the client broadcasts own INFO packet to all other nodes. 41 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_discover.png) 42 | 43 | ### Heartbeat 44 | 45 | The client has to broadcast `HEARTBEAT` packets periodically. The period value comes from broker options (`heartbeatInterval`). The default value is 5 secs. 46 | If the client does not receive `HEARTBEAT` for `heartbeatTimeout` seconds from a node, marks it broken and doesn't route requests to this node. 47 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_heartbeat.png) 48 | 49 | ### Request-reply 50 | 51 | When you call the `broker.call` method, the broker sends a `REQUEST` packet to the targeted node. It processes the request and sends back a `RESPONSE` packet to the requester node. 52 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_request.png) 53 | 54 | ### Event 55 | 56 | When you call the `broker.emit` method, the broker sends an `EVENT` packet to the subscriber nodes. The broker groups & balances the subscribers, so only one instance per service receives the event. If you call the `broker.broadcast` method, the broker sends an `ĘVENT` packet to all subscriber nodes. It doesn't balance the subscribers. 57 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_event.png) 58 | 59 | ### Ping-pong 60 | 61 | When you call the `broker.ping` method, the broker sends a `PING` packet to the targeted node. If node is not defined, it sends to all nodes. If the client receives the `PING` packet, sends back a `PONG` response packet. If it receives, broker broadcasts a local `$node.pong` event to the local services. 62 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_pong.png) 63 | 64 | ### Disconnect 65 | 66 | When a node is stopping, it broadcasts a `DISCONNECT` packet to all nodes. 67 | ![](http://moleculer.services/images/protocol-v2/moleculer_protocol_disconnect.png) 68 | 69 | ## Protocol messages 70 | 71 | ### `DISCOVER` 72 | 73 | When the transporter established the connection with the message broker, it broadcasts a `DISCOVER` message to all other nodes. 74 | 75 | **Topic name:** 76 | 77 | - `MOL.DISCOVER` (if broadcasts) 78 | - `MOL.DISCOVER.node-1` (if sent only to `node-1`) 79 | - `MOL-dev.DISCOVER` (if namespace is `dev`) 80 | 81 | **Fields:** 82 | 83 | | Field | Type | Required | Description | 84 | | -------- | -------- | -------- | ----------------- | 85 | | `ver` | `string` | ✔ | Protocol version. | 86 | | `sender` | `string` | ✔ | Sender nodeID. | 87 | 88 | **Example with JSON serializer** 89 | 90 | ```json 91 | { 92 | "ver": "4", 93 | "sender": "node-100" 94 | } 95 | ``` 96 | 97 | ### `INFO` 98 | 99 | When the node receives an `INFO` packet, it sends an `INFO` packet which contains all mandatory information about the nodes and the loaded services. 100 | 101 | **Topic name:** 102 | 103 | - `MOL.INFO` (if broadcasts) 104 | - `MOL.INFO.node-1` (if sent only to `node-1`) 105 | - `MOL-dev.INFO` (if namespace is `dev`) 106 | 107 | **Fields:** 108 | 109 | | Field | Type | Required | Description | 110 | | -------------------- | ---------- | -------- | ----------------------------------------------------- | 111 | | `ver` | `string` | ✔ | Protocol version. | 112 | | `sender` | `string` | ✔ | Sender nodeID. | 113 | | `services` | `object` | ✔ | Services list. (\*) | 114 | | `config` | `object` | ✔ | Client configuration. (\*) | 115 | | `instanceID` | `string` | ✔ | Instance ID | 116 | | `ipList` | `[string]` | ✔ | IP address list of node | 117 | | `hostname` | `string` | ✔ | Hostname of node | 118 | | `client` | `object` | ✔ | Client information | 119 | | `client.type` | `string` | ✔ | Type of client implementation(`nodejs`, `java`, `go`) | 120 | | `client.version` | `string` | ✔ | Client (Moleculer) version | 121 | | `client.langVersion` | `string` | ✔ | NodeJS/Java/Go version | 122 | | `metadata` | `object` | ✔ | Node-specific metadata. (\*) | 123 | 124 | > (\*) In case of schema-based serializers, the field value is encoded to JSON string. 125 | 126 | **Example with JSON serializer** 127 | 128 | ```json 129 | { 130 | "services": [ 131 | { 132 | "name": "$node", 133 | "settings": {}, 134 | "metadata": {}, 135 | "actions": [], 136 | "events": {} 137 | }, 138 | { 139 | "name": "greeter", 140 | "settings": {}, 141 | "metadata": {}, 142 | "actions": [], 143 | "events": {} 144 | } 145 | ], 146 | "ipList": ["10.35.0.34"], 147 | "hostname": "moleculer-server", 148 | "client": { 149 | "type": "nodejs", 150 | "version": "0.14.0-beta3", 151 | "langVersion": "v12.10.0" 152 | }, 153 | "config": {}, 154 | "instanceID": "ee21e97d-9fd0-4d7e-a303-70b1605f477f", 155 | "metadata": {}, 156 | "seq": 2, 157 | "ver": "4", 158 | "sender": "nodeID-1" 159 | } 160 | ``` 161 | 162 | ### `HEARTBEAT` 163 | 164 | **Topic name:** 165 | 166 | - `MOL.HEARTBEAT` 167 | - `MOL-dev.HEARTBEAT` (if namespace is `dev`) 168 | 169 | **Fields:** 170 | 171 | | Field | Type | Required | Description | 172 | | -------- | -------- | -------- | ------------------------------------- | 173 | | `ver` | `string` | ✔ | Protocol version. | 174 | | `sender` | `string` | ✔ | Sender nodeID. | 175 | | `cpu` | `double` | ✔ | Current CPU utilization (percentage). | 176 | 177 | **Example with JSON serializer** 178 | 179 | ```json 180 | { 181 | "ver": "4", 182 | "sender": "node-100", 183 | "cpu": 13.5 184 | } 185 | ``` 186 | 187 | ### `REQUEST` 188 | 189 | **Topic name:** 190 | 191 | - `MOL.REQ.node-2` 192 | - `MOL.REQB.` (if built-in balancer is disabled) 193 | - `MOL-dev.REQ.node-2` (if namespace is `dev`) 194 | 195 | **Fields:** 196 | 197 | | Field | Type | Required | Description | 198 | | ------------ | --------- | -------- | ---------------------------------------------- | 199 | | `ver` | `string` | ✔ | Protocol version. | 200 | | `sender` | `string` | ✔ | Sender nodeID. | 201 | | `id` | `string` | ✔ | Context ID. | 202 | | `action` | `string` | ✔ | Action name. E.g.: `posts.find` | 203 | | `params` | `object` | | `ctx.params` object. (\*\*) | 204 | | `paramsType` | `enum` | ✔ | Data type of `ctx.params`. (\*\*\*) | 205 | | `meta` | `object` | ✔ | `ctx.meta` object. (\*) | 206 | | `timeout` | `double` | ✔ | Request timeout (distributed) in milliseconds. | 207 | | `level` | `int32` | ✔ | Level of request. | 208 | | `tracing` | `boolean` | ✔ | Need to send tracing events. | 209 | | `parentID` | `string` | | Parent context ID. | 210 | | `requestID` | `string` | | Request ID from `ctx.requestID`. | 211 | | `caller` | `string` | | Action name of the caller. | 212 | | `stream` | `boolean` | ✔ | Stream request. | 213 | | `seq` | `int32` | | Stream sequence number. | 214 | 215 | > (\*) In case of schema-based serializers, the field value is encoded to JSON string. 216 | 217 | > (\*\*) In case of schema-based serializers, the field value is encoded to JSON string and transferred as binary data. 218 | 219 | > (\*\*\*) Used only in `ProtoBuf`, `Avro`, `Thrift` or any other schema-based serializer to detect the original type of data. 220 | 221 | **Example with JSON serializer** 222 | 223 | ```json 224 | { 225 | "id": "41238213-da6b-4313-9909-e6edd0e40a96", 226 | "action": "greeter.hello", 227 | "params": {}, 228 | "meta": {}, 229 | "timeout": 10000, 230 | "level": 1, 231 | "tracing": null, 232 | "parentID": null, 233 | "requestID": "41238213-da6b-4313-9909-e6edd0e40a96", 234 | "caller": null, 235 | "stream": false, 236 | "ver": "4", 237 | "sender": "nodeID-1" 238 | } 239 | ``` 240 | 241 | ### `RESPONSE` 242 | 243 | **Topic name:** 244 | 245 | - `MOL.RES.node-1` 246 | - `MOL-dev.RES.node-1` (if namespace is `dev`) 247 | 248 | **Fields:** 249 | 250 | | Field | Type | Required | Description | 251 | | ---------- | --------- | -------- | ----------------------------------- | 252 | | `ver` | `string` | ✔ | Protocol version. | 253 | | `sender` | `string` | ✔ | Sender nodeID. | 254 | | `id` | `string` | ✔ | Context ID (from `REQUEST`). | 255 | | `success` | `boolean` | ✔ | Is it a success response? | 256 | | `data` | `object` | | Response data if success. (\*\*) | 257 | | `dataType` | `enum` | ✔ | Data type of `ctx.params`. (\*\*\*) | 258 | | `error` | `object` | | Error object if not success. (\*) | 259 | | `meta` | `object` | ✔ | `ctx.meta` object. (\*) | 260 | | `stream` | `boolean` | ✔ | Stream request. | 261 | | `seq` | `int32` | | Stream sequence number. | 262 | 263 | > (\*) In case of schema-based serializers, the field value is encoded to JSON string. 264 | 265 | > (\*\*) In case of schema-based serializers, the field value is encoded to JSON string and transferred as binary data. 266 | 267 | > (\*\*\*) Used only in `ProtoBuf`, `Avro`, `Thrift` or any other schema-based serializer to detect the original type of data. 268 | 269 | **Example with JSON serializer** 270 | 271 | ```json 272 | { 273 | "id": "a4dd3ae5-2eff-4924-94bc-4acb8ac034aa", 274 | "meta": {}, 275 | "success": true, 276 | "data": { 277 | "message": "Hello Moleculer" 278 | }, 279 | "ver": "4", 280 | "sender": "nodeID-2" 281 | } 282 | ``` 283 | 284 | ### `EVENT` 285 | 286 | **Topic name:** 287 | 288 | - `MOL.EVENT.node-1` 289 | - `MOL.EVENTB..` (if built-in balancer is disabled) 290 | - `MOL-dev.EVENT.node-1` (if namespace is `dev`) 291 | 292 | **Fields:** 293 | 294 | | Field | Type | Required | Description | 295 | | ----------- | --------------- | -------- | ----------------------------------- | 296 | | `ver` | `string` | ✔ | Protocol version. | 297 | | `sender` | `string` | ✔ | Sender nodeID. | 298 | | `id` | `string` | ✔ | Context ID. | 299 | | `event` | `string` | ✔ | Event name. E.g.: `users.created` | 300 | | `data` | `object` | | Event payload. (\*\*) | 301 | | `dataType` | `enum` | ✔ | Data type of `ctx.params`. (\*\*\*) | 302 | | `meta` | `object` | ✔ | `ctx.meta` object. (\*) | 303 | | `level` | `int32` | ✔ | Level of event. | 304 | | `tracing` | `boolean` | ✔ | Need to send tracing events. | 305 | | `parentID` | `string` | | Parent context ID. | 306 | | `requestID` | `string` | | Request ID from `ctx.requestID`. | 307 | | `caller` | `string` | | Action/Event name of the caller. | 308 | | `stream` | `boolean` | ✔ | Stream request. | 309 | | `seq` | `int32` | | Stream sequence number. | 310 | | `groups` | `Array` | | Groups for balanced events. | 311 | | `broadcast` | `boolean` | ✔ | Broadcast event | 312 | 313 | > (\*) In case of schema-based serializers, the field value is encoded to JSON string. 314 | 315 | > (\*\*) In case of schema-based serializers, the field value is encoded to JSON string and transferred as binary data. 316 | 317 | > (\*\*\*) Used only in `ProtoBuf`, `Avro`, `Thrift` or any other schema-based serializer to detect the original type of data. 318 | 319 | **Example with JSON serializer** 320 | 321 | ```json 322 | { 323 | "id": "e102630b-c702-4ff9-a0a1-52428395d57a", 324 | "event": "some.test", 325 | "data": { 326 | "name": "John" 327 | }, 328 | "groups": ["greeter"], 329 | "broadcast": false, 330 | "meta": {}, 331 | "level": 1, 332 | "tracing": null, 333 | "parentID": null, 334 | "requestID": "e102630b-c702-4ff9-a0a1-52428395d57a", 335 | "caller": null, 336 | "needAck": null, 337 | "ver": "4", 338 | "sender": "nodeID-1" 339 | } 340 | ``` 341 | 342 | ### `EVENTACK` 343 | 344 | **_Not implemented yet._** 345 | 346 | **Topic name:** 347 | 348 | - `MOL.EVENTACK.node-1` 349 | - `MOL-dev.EVENTACK` (if namespace is `dev`) 350 | 351 | **Fields:** 352 | 353 | | Field | Type | Required | Description | 354 | | --------- | --------- | -------- | --------------------------------- | 355 | | `ver` | `string` | ✔ | Protocol version. | 356 | | `sender` | `string` | ✔ | Sender nodeID. | 357 | | `id` | `string` | ✔ | Event Context ID. | 358 | | `success` | `boolean` | ✔ | Is it successful? | 359 | | `group` | `string` | | Group of event handler. | 360 | | `error` | `object` | | Error object if not success. (\*) | 361 | 362 | > (\*) In case of schema-based serializers, the field value is encoded to JSON string. 363 | 364 | **Example with JSON serializer** 365 | 366 | ```json 367 | { 368 | "ver": "4", 369 | "sender": "node-100" 370 | } 371 | ``` 372 | 373 | !!TODO!! 374 | 375 | ### `PING` 376 | 377 | **Topic name:** 378 | 379 | - `MOL.PING` (if broadcasts) 380 | - `MOL.PING.node-1` (if sent only to `node-1`) 381 | - `MOL-dev.PING` (if namespace is `dev`) 382 | 383 | **Fields:** 384 | 385 | | Field | Type | Required | Description | 386 | | -------- | -------- | -------- | ------------------ | 387 | | `ver` | `string` | ✔ | Protocol version. | 388 | | `sender` | `string` | ✔ | Sender nodeID. | 389 | | `id` | `string` | ✔ | Message ID. | 390 | | `time` | `int64` | ✔ | Time of sent. (\*) | 391 | 392 | > (\*) The number of milliseconds between 1 January 1970 00:00:00 UTC and the given date. 393 | 394 | **Example with JSON serializer** 395 | 396 | ```json 397 | { 398 | "time": 1567677050576, 399 | "id": "3e09738f-cedf-4985-85fe-344860c06cfd", 400 | "ver": "4", 401 | "sender": "nodeID-2" 402 | } 403 | ``` 404 | 405 | ### `PONG` 406 | 407 | **Topic name:** 408 | 409 | - `MOL.PONG.node-1` 410 | - `MOL-dev.PONG` (if namespace is `dev`) 411 | 412 | **Fields:** 413 | 414 | | Field | Type | Required | Description | 415 | | --------- | -------- | -------- | -------------------------- | 416 | | `ver` | `string` | ✔ | Protocol version. | 417 | | `sender` | `string` | ✔ | Sender nodeID. | 418 | | `id` | `string` | ✔ | Message ID. | 419 | | `time` | `int64` | ✔ | Timestamp of sent. (\*) | 420 | | `arrived` | `int64` | ✔ | Timestamp of arrived. (\*) | 421 | 422 | > (\*) The number of milliseconds between 1 January 1970 00:00:00 UTC and the given date. 423 | 424 | **Example with JSON serializer** 425 | 426 | ```json 427 | { 428 | "time": 1567677050576, 429 | "id": "3e09738f-cedf-4985-85fe-344860c06cfd", 430 | "arrived": 1567677050577, 431 | "ver": "4", 432 | "sender": "nodeID-1" 433 | } 434 | ``` 435 | 436 | ### `DISCONNECT` 437 | 438 | **Topic name:** 439 | 440 | - `MOL.DISCONNECT` 441 | - `MOL-dev.DISCONNECT` (if namespace is `dev`) 442 | 443 | **Fields:** 444 | 445 | | Field | Type | Required | Description | 446 | | -------- | -------- | -------- | ----------------- | 447 | | `ver` | `string` | ✔ | Protocol version. | 448 | | `sender` | `string` | ✔ | Sender nodeID. | 449 | 450 | **Example with JSON serializer** 451 | 452 | ```json 453 | { 454 | "ver": "4", 455 | "sender": "node-100" 456 | } 457 | ``` 458 | 459 | ## Graceful starting & stopping 460 | 461 | ### Start 462 | 463 | The broker starts by establishing connection with the `transporter` (e.g., NATS server, MQTT broker). After successfully establishing the connection, it starts all services, i.e., calls service `started` handlers. Once all services have started successfully, broker publishes the local service list to remote nodes. Hence remote nodes will send requests only after all local service have started properly. 464 | 465 | **Start lifecycle sequence** 466 | 467 | ![image](media/broker-start.svg) 468 | 469 | ### Stop 470 | 471 | When broker is stopping, it starts by publishing an empty service list to all remote nodes. This is done to inform all remote nodes that the node and it's service will be shut down. Next, broker starts stopping all local services. After that, the transporter disconnects. 472 | 473 | **Stop lifecycle sequence** 474 | 475 | ![image](media/broker-stop.svg) 476 | 477 | ## Streams 478 | 479 | While transferring streams, sequence number (`seq`) field is used to keep track of the chunks and their order. This is especially important in "multi-threaded systems" that can shuffle the packets before sending them. If packets arrive unordered they are stored in a pool until previous chucks arrive. 480 | 481 | ## Disabled built-in balancer mode 482 | 483 | When built-in load balancing mechanisms are disabled, the balancing is done by the brokers (e.g., NATS, RabbitMQ). This means that there are no local calls in actions and events. All requests are transferred to transporter that will be responsible for choosing the destination of the request and delivery of the message. 484 | 485 | ## Changes from version `3` 486 | 487 | **INFO** 488 | - added `instanceID: string` 489 | - added `metadata: object` specific to each nodes 490 | 491 | **PING / PONG** 492 | - added messaged ID `id: string` on both message types 493 | 494 | **REQUEST** 495 | - `params` now is not required anymore 496 | - removed `metrics` property and added `tracing: boolean` whether tracing events is needed 497 | - new `paramsType: enum` needed for schema-based serializers 498 | - new `caller: string` property for action name of the caller 499 | - new `seq: int32` to have better tracking of stream request 500 | 501 | **RESPONSE** 502 | - new `dataType: enum` needed for schema-based serializers 503 | - new `seq: int32` to have better tracking of stream request 504 | 505 | **EVENT** 506 | - added context ID `id: string` in the payload 507 | - new `dataType: enum` needed for schema-based serializers 508 | - new `meta: object` that represents `ctx.meta` object 509 | - added `level: int32` as level of the event 510 | - added `tracing: boolean` whether tracing events is needed 511 | - new `caller: string` property for action/event name of the caller 512 | - added parent context ID `parentID: string` 513 | - added `requestID` from context in the payload 514 | - handled stream requests, hence we have new properties `stream: boolean` whether it's a stream request and `seq: int32` to have better tracking 515 | -------------------------------------------------------------------------------- /3.0/thrift/gen-nodejs/packets_types.js: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Thrift Compiler (0.11.0) 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | "use strict"; 7 | 8 | let thrift = require("thrift"); 9 | let Thrift = thrift.Thrift; 10 | let Q = thrift.Q; 11 | 12 | 13 | let ttypes = module.exports = {}; 14 | /* istanbul ignore next */ 15 | let PacketEvent = module.exports.PacketEvent = function(args) { 16 | this.ver = null; 17 | this.sender = null; 18 | this.event = null; 19 | this.data = null; 20 | this.groups = null; 21 | this.broadcast = null; 22 | if (args) { 23 | if (args.ver !== undefined && args.ver !== null) { 24 | this.ver = args.ver; 25 | } 26 | if (args.sender !== undefined && args.sender !== null) { 27 | this.sender = args.sender; 28 | } 29 | if (args.event !== undefined && args.event !== null) { 30 | this.event = args.event; 31 | } 32 | if (args.data !== undefined && args.data !== null) { 33 | this.data = args.data; 34 | } 35 | if (args.groups !== undefined && args.groups !== null) { 36 | this.groups = Thrift.copyList(args.groups, [null]); 37 | } 38 | if (args.broadcast !== undefined && args.broadcast !== null) { 39 | this.broadcast = args.broadcast; 40 | } 41 | } 42 | }; 43 | PacketEvent.prototype = {}; 44 | PacketEvent.prototype.read = function(input) { 45 | input.readStructBegin(); 46 | while (true) 47 | { 48 | let ret = input.readFieldBegin(); 49 | let fname = ret.fname; 50 | let ftype = ret.ftype; 51 | let fid = ret.fid; 52 | if (ftype == Thrift.Type.STOP) { 53 | break; 54 | } 55 | switch (fid) 56 | { 57 | case 1: 58 | if (ftype == Thrift.Type.STRING) { 59 | this.ver = input.readString(); 60 | } else { 61 | input.skip(ftype); 62 | } 63 | break; 64 | case 2: 65 | if (ftype == Thrift.Type.STRING) { 66 | this.sender = input.readString(); 67 | } else { 68 | input.skip(ftype); 69 | } 70 | break; 71 | case 3: 72 | if (ftype == Thrift.Type.STRING) { 73 | this.event = input.readString(); 74 | } else { 75 | input.skip(ftype); 76 | } 77 | break; 78 | case 4: 79 | if (ftype == Thrift.Type.STRING) { 80 | this.data = input.readString(); 81 | } else { 82 | input.skip(ftype); 83 | } 84 | break; 85 | case 5: 86 | if (ftype == Thrift.Type.LIST) { 87 | let _size0 = 0; 88 | var _rtmp34; 89 | this.groups = []; 90 | let _etype3 = 0; 91 | _rtmp34 = input.readListBegin(); 92 | _etype3 = _rtmp34.etype; 93 | _size0 = _rtmp34.size; 94 | for (let _i5 = 0; _i5 < _size0; ++_i5) 95 | { 96 | let elem6 = null; 97 | elem6 = input.readString(); 98 | this.groups.push(elem6); 99 | } 100 | input.readListEnd(); 101 | } else { 102 | input.skip(ftype); 103 | } 104 | break; 105 | case 6: 106 | if (ftype == Thrift.Type.BOOL) { 107 | this.broadcast = input.readBool(); 108 | } else { 109 | input.skip(ftype); 110 | } 111 | break; 112 | default: 113 | input.skip(ftype); 114 | } 115 | input.readFieldEnd(); 116 | } 117 | input.readStructEnd(); 118 | return; 119 | }; 120 | 121 | PacketEvent.prototype.write = function(output) { 122 | output.writeStructBegin("PacketEvent"); 123 | if (this.ver !== null && this.ver !== undefined) { 124 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 125 | output.writeString(this.ver); 126 | output.writeFieldEnd(); 127 | } 128 | if (this.sender !== null && this.sender !== undefined) { 129 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 130 | output.writeString(this.sender); 131 | output.writeFieldEnd(); 132 | } 133 | if (this.event !== null && this.event !== undefined) { 134 | output.writeFieldBegin("event", Thrift.Type.STRING, 3); 135 | output.writeString(this.event); 136 | output.writeFieldEnd(); 137 | } 138 | if (this.data !== null && this.data !== undefined) { 139 | output.writeFieldBegin("data", Thrift.Type.STRING, 4); 140 | output.writeString(this.data); 141 | output.writeFieldEnd(); 142 | } 143 | if (this.groups !== null && this.groups !== undefined) { 144 | output.writeFieldBegin("groups", Thrift.Type.LIST, 5); 145 | output.writeListBegin(Thrift.Type.STRING, this.groups.length); 146 | for (let iter7 in this.groups) 147 | { 148 | if (this.groups.hasOwnProperty(iter7)) 149 | { 150 | iter7 = this.groups[iter7]; 151 | output.writeString(iter7); 152 | } 153 | } 154 | output.writeListEnd(); 155 | output.writeFieldEnd(); 156 | } 157 | if (this.broadcast !== null && this.broadcast !== undefined) { 158 | output.writeFieldBegin("broadcast", Thrift.Type.BOOL, 6); 159 | output.writeBool(this.broadcast); 160 | output.writeFieldEnd(); 161 | } 162 | output.writeFieldStop(); 163 | output.writeStructEnd(); 164 | return; 165 | }; 166 | 167 | let PacketRequest = module.exports.PacketRequest = function(args) { 168 | this.ver = null; 169 | this.sender = null; 170 | this.id = null; 171 | this.action = null; 172 | this.params = null; 173 | this.meta = null; 174 | this.timeout = null; 175 | this.level = null; 176 | this.metrics = null; 177 | this.parentID = null; 178 | this.requestID = null; 179 | this.stream = null; 180 | if (args) { 181 | if (args.ver !== undefined && args.ver !== null) { 182 | this.ver = args.ver; 183 | } 184 | if (args.sender !== undefined && args.sender !== null) { 185 | this.sender = args.sender; 186 | } 187 | if (args.id !== undefined && args.id !== null) { 188 | this.id = args.id; 189 | } 190 | if (args.action !== undefined && args.action !== null) { 191 | this.action = args.action; 192 | } 193 | if (args.params !== undefined && args.params !== null) { 194 | this.params = args.params; 195 | } 196 | if (args.meta !== undefined && args.meta !== null) { 197 | this.meta = args.meta; 198 | } 199 | if (args.timeout !== undefined && args.timeout !== null) { 200 | this.timeout = args.timeout; 201 | } 202 | if (args.level !== undefined && args.level !== null) { 203 | this.level = args.level; 204 | } 205 | if (args.metrics !== undefined && args.metrics !== null) { 206 | this.metrics = args.metrics; 207 | } 208 | if (args.parentID !== undefined && args.parentID !== null) { 209 | this.parentID = args.parentID; 210 | } 211 | if (args.requestID !== undefined && args.requestID !== null) { 212 | this.requestID = args.requestID; 213 | } 214 | if (args.stream !== undefined && args.stream !== null) { 215 | this.stream = args.stream; 216 | } 217 | } 218 | }; 219 | PacketRequest.prototype = {}; 220 | PacketRequest.prototype.read = function(input) { 221 | input.readStructBegin(); 222 | while (true) 223 | { 224 | let ret = input.readFieldBegin(); 225 | let fname = ret.fname; 226 | let ftype = ret.ftype; 227 | let fid = ret.fid; 228 | if (ftype == Thrift.Type.STOP) { 229 | break; 230 | } 231 | switch (fid) 232 | { 233 | case 1: 234 | if (ftype == Thrift.Type.STRING) { 235 | this.ver = input.readString(); 236 | } else { 237 | input.skip(ftype); 238 | } 239 | break; 240 | case 2: 241 | if (ftype == Thrift.Type.STRING) { 242 | this.sender = input.readString(); 243 | } else { 244 | input.skip(ftype); 245 | } 246 | break; 247 | case 3: 248 | if (ftype == Thrift.Type.STRING) { 249 | this.id = input.readString(); 250 | } else { 251 | input.skip(ftype); 252 | } 253 | break; 254 | case 4: 255 | if (ftype == Thrift.Type.STRING) { 256 | this.action = input.readString(); 257 | } else { 258 | input.skip(ftype); 259 | } 260 | break; 261 | case 5: 262 | if (ftype == Thrift.Type.STRING) { 263 | this.params = input.readBinary(); 264 | } else { 265 | input.skip(ftype); 266 | } 267 | break; 268 | case 6: 269 | if (ftype == Thrift.Type.STRING) { 270 | this.meta = input.readString(); 271 | } else { 272 | input.skip(ftype); 273 | } 274 | break; 275 | case 7: 276 | if (ftype == Thrift.Type.DOUBLE) { 277 | this.timeout = input.readDouble(); 278 | } else { 279 | input.skip(ftype); 280 | } 281 | break; 282 | case 8: 283 | if (ftype == Thrift.Type.I32) { 284 | this.level = input.readI32(); 285 | } else { 286 | input.skip(ftype); 287 | } 288 | break; 289 | case 9: 290 | if (ftype == Thrift.Type.BOOL) { 291 | this.metrics = input.readBool(); 292 | } else { 293 | input.skip(ftype); 294 | } 295 | break; 296 | case 10: 297 | if (ftype == Thrift.Type.STRING) { 298 | this.parentID = input.readString(); 299 | } else { 300 | input.skip(ftype); 301 | } 302 | break; 303 | case 11: 304 | if (ftype == Thrift.Type.STRING) { 305 | this.requestID = input.readString(); 306 | } else { 307 | input.skip(ftype); 308 | } 309 | break; 310 | case 12: 311 | if (ftype == Thrift.Type.BOOL) { 312 | this.stream = input.readBool(); 313 | } else { 314 | input.skip(ftype); 315 | } 316 | break; 317 | default: 318 | input.skip(ftype); 319 | } 320 | input.readFieldEnd(); 321 | } 322 | input.readStructEnd(); 323 | return; 324 | }; 325 | 326 | PacketRequest.prototype.write = function(output) { 327 | output.writeStructBegin("PacketRequest"); 328 | if (this.ver !== null && this.ver !== undefined) { 329 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 330 | output.writeString(this.ver); 331 | output.writeFieldEnd(); 332 | } 333 | if (this.sender !== null && this.sender !== undefined) { 334 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 335 | output.writeString(this.sender); 336 | output.writeFieldEnd(); 337 | } 338 | if (this.id !== null && this.id !== undefined) { 339 | output.writeFieldBegin("id", Thrift.Type.STRING, 3); 340 | output.writeString(this.id); 341 | output.writeFieldEnd(); 342 | } 343 | if (this.action !== null && this.action !== undefined) { 344 | output.writeFieldBegin("action", Thrift.Type.STRING, 4); 345 | output.writeString(this.action); 346 | output.writeFieldEnd(); 347 | } 348 | if (this.params !== null && this.params !== undefined) { 349 | output.writeFieldBegin("params", Thrift.Type.STRING, 5); 350 | output.writeBinary(this.params); 351 | output.writeFieldEnd(); 352 | } 353 | if (this.meta !== null && this.meta !== undefined) { 354 | output.writeFieldBegin("meta", Thrift.Type.STRING, 6); 355 | output.writeString(this.meta); 356 | output.writeFieldEnd(); 357 | } 358 | if (this.timeout !== null && this.timeout !== undefined) { 359 | output.writeFieldBegin("timeout", Thrift.Type.DOUBLE, 7); 360 | output.writeDouble(this.timeout); 361 | output.writeFieldEnd(); 362 | } 363 | if (this.level !== null && this.level !== undefined) { 364 | output.writeFieldBegin("level", Thrift.Type.I32, 8); 365 | output.writeI32(this.level); 366 | output.writeFieldEnd(); 367 | } 368 | if (this.metrics !== null && this.metrics !== undefined) { 369 | output.writeFieldBegin("metrics", Thrift.Type.BOOL, 9); 370 | output.writeBool(this.metrics); 371 | output.writeFieldEnd(); 372 | } 373 | if (this.parentID !== null && this.parentID !== undefined) { 374 | output.writeFieldBegin("parentID", Thrift.Type.STRING, 10); 375 | output.writeString(this.parentID); 376 | output.writeFieldEnd(); 377 | } 378 | if (this.requestID !== null && this.requestID !== undefined) { 379 | output.writeFieldBegin("requestID", Thrift.Type.STRING, 11); 380 | output.writeString(this.requestID); 381 | output.writeFieldEnd(); 382 | } 383 | if (this.stream !== null && this.stream !== undefined) { 384 | output.writeFieldBegin("stream", Thrift.Type.BOOL, 12); 385 | output.writeBool(this.stream); 386 | output.writeFieldEnd(); 387 | } 388 | output.writeFieldStop(); 389 | output.writeStructEnd(); 390 | return; 391 | }; 392 | 393 | let PacketResponse = module.exports.PacketResponse = function(args) { 394 | this.ver = null; 395 | this.sender = null; 396 | this.id = null; 397 | this.success = null; 398 | this.data = null; 399 | this.error = null; 400 | this.meta = null; 401 | this.stream = null; 402 | if (args) { 403 | if (args.ver !== undefined && args.ver !== null) { 404 | this.ver = args.ver; 405 | } 406 | if (args.sender !== undefined && args.sender !== null) { 407 | this.sender = args.sender; 408 | } 409 | if (args.id !== undefined && args.id !== null) { 410 | this.id = args.id; 411 | } 412 | if (args.success !== undefined && args.success !== null) { 413 | this.success = args.success; 414 | } 415 | if (args.data !== undefined && args.data !== null) { 416 | this.data = args.data; 417 | } 418 | if (args.error !== undefined && args.error !== null) { 419 | this.error = args.error; 420 | } 421 | if (args.meta !== undefined && args.meta !== null) { 422 | this.meta = args.meta; 423 | } 424 | if (args.stream !== undefined && args.stream !== null) { 425 | this.stream = args.stream; 426 | } 427 | } 428 | }; 429 | PacketResponse.prototype = {}; 430 | PacketResponse.prototype.read = function(input) { 431 | input.readStructBegin(); 432 | while (true) 433 | { 434 | let ret = input.readFieldBegin(); 435 | let fname = ret.fname; 436 | let ftype = ret.ftype; 437 | let fid = ret.fid; 438 | if (ftype == Thrift.Type.STOP) { 439 | break; 440 | } 441 | switch (fid) 442 | { 443 | case 1: 444 | if (ftype == Thrift.Type.STRING) { 445 | this.ver = input.readString(); 446 | } else { 447 | input.skip(ftype); 448 | } 449 | break; 450 | case 2: 451 | if (ftype == Thrift.Type.STRING) { 452 | this.sender = input.readString(); 453 | } else { 454 | input.skip(ftype); 455 | } 456 | break; 457 | case 3: 458 | if (ftype == Thrift.Type.STRING) { 459 | this.id = input.readString(); 460 | } else { 461 | input.skip(ftype); 462 | } 463 | break; 464 | case 4: 465 | if (ftype == Thrift.Type.BOOL) { 466 | this.success = input.readBool(); 467 | } else { 468 | input.skip(ftype); 469 | } 470 | break; 471 | case 5: 472 | if (ftype == Thrift.Type.STRING) { 473 | this.data = input.readBinary(); 474 | } else { 475 | input.skip(ftype); 476 | } 477 | break; 478 | case 6: 479 | if (ftype == Thrift.Type.STRING) { 480 | this.error = input.readString(); 481 | } else { 482 | input.skip(ftype); 483 | } 484 | break; 485 | case 7: 486 | if (ftype == Thrift.Type.STRING) { 487 | this.meta = input.readString(); 488 | } else { 489 | input.skip(ftype); 490 | } 491 | break; 492 | case 8: 493 | if (ftype == Thrift.Type.BOOL) { 494 | this.stream = input.readBool(); 495 | } else { 496 | input.skip(ftype); 497 | } 498 | break; 499 | default: 500 | input.skip(ftype); 501 | } 502 | input.readFieldEnd(); 503 | } 504 | input.readStructEnd(); 505 | return; 506 | }; 507 | 508 | PacketResponse.prototype.write = function(output) { 509 | output.writeStructBegin("PacketResponse"); 510 | if (this.ver !== null && this.ver !== undefined) { 511 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 512 | output.writeString(this.ver); 513 | output.writeFieldEnd(); 514 | } 515 | if (this.sender !== null && this.sender !== undefined) { 516 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 517 | output.writeString(this.sender); 518 | output.writeFieldEnd(); 519 | } 520 | if (this.id !== null && this.id !== undefined) { 521 | output.writeFieldBegin("id", Thrift.Type.STRING, 3); 522 | output.writeString(this.id); 523 | output.writeFieldEnd(); 524 | } 525 | if (this.success !== null && this.success !== undefined) { 526 | output.writeFieldBegin("success", Thrift.Type.BOOL, 4); 527 | output.writeBool(this.success); 528 | output.writeFieldEnd(); 529 | } 530 | if (this.data !== null && this.data !== undefined) { 531 | output.writeFieldBegin("data", Thrift.Type.STRING, 5); 532 | output.writeBinary(this.data); 533 | output.writeFieldEnd(); 534 | } 535 | if (this.error !== null && this.error !== undefined) { 536 | output.writeFieldBegin("error", Thrift.Type.STRING, 6); 537 | output.writeString(this.error); 538 | output.writeFieldEnd(); 539 | } 540 | if (this.meta !== null && this.meta !== undefined) { 541 | output.writeFieldBegin("meta", Thrift.Type.STRING, 7); 542 | output.writeString(this.meta); 543 | output.writeFieldEnd(); 544 | } 545 | if (this.stream !== null && this.stream !== undefined) { 546 | output.writeFieldBegin("stream", Thrift.Type.BOOL, 8); 547 | output.writeBool(this.stream); 548 | output.writeFieldEnd(); 549 | } 550 | output.writeFieldStop(); 551 | output.writeStructEnd(); 552 | return; 553 | }; 554 | 555 | let PacketDiscover = module.exports.PacketDiscover = function(args) { 556 | this.ver = null; 557 | this.sender = null; 558 | if (args) { 559 | if (args.ver !== undefined && args.ver !== null) { 560 | this.ver = args.ver; 561 | } 562 | if (args.sender !== undefined && args.sender !== null) { 563 | this.sender = args.sender; 564 | } 565 | } 566 | }; 567 | PacketDiscover.prototype = {}; 568 | PacketDiscover.prototype.read = function(input) { 569 | input.readStructBegin(); 570 | while (true) 571 | { 572 | let ret = input.readFieldBegin(); 573 | let fname = ret.fname; 574 | let ftype = ret.ftype; 575 | let fid = ret.fid; 576 | if (ftype == Thrift.Type.STOP) { 577 | break; 578 | } 579 | switch (fid) 580 | { 581 | case 1: 582 | if (ftype == Thrift.Type.STRING) { 583 | this.ver = input.readString(); 584 | } else { 585 | input.skip(ftype); 586 | } 587 | break; 588 | case 2: 589 | if (ftype == Thrift.Type.STRING) { 590 | this.sender = input.readString(); 591 | } else { 592 | input.skip(ftype); 593 | } 594 | break; 595 | default: 596 | input.skip(ftype); 597 | } 598 | input.readFieldEnd(); 599 | } 600 | input.readStructEnd(); 601 | return; 602 | }; 603 | 604 | PacketDiscover.prototype.write = function(output) { 605 | output.writeStructBegin("PacketDiscover"); 606 | if (this.ver !== null && this.ver !== undefined) { 607 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 608 | output.writeString(this.ver); 609 | output.writeFieldEnd(); 610 | } 611 | if (this.sender !== null && this.sender !== undefined) { 612 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 613 | output.writeString(this.sender); 614 | output.writeFieldEnd(); 615 | } 616 | output.writeFieldStop(); 617 | output.writeStructEnd(); 618 | return; 619 | }; 620 | 621 | let Client = module.exports.Client = function(args) { 622 | this.type = null; 623 | this.version = null; 624 | this.langVersion = null; 625 | if (args) { 626 | if (args.type !== undefined && args.type !== null) { 627 | this.type = args.type; 628 | } 629 | if (args.version !== undefined && args.version !== null) { 630 | this.version = args.version; 631 | } 632 | if (args.langVersion !== undefined && args.langVersion !== null) { 633 | this.langVersion = args.langVersion; 634 | } 635 | } 636 | }; 637 | Client.prototype = {}; 638 | Client.prototype.read = function(input) { 639 | input.readStructBegin(); 640 | while (true) 641 | { 642 | let ret = input.readFieldBegin(); 643 | let fname = ret.fname; 644 | let ftype = ret.ftype; 645 | let fid = ret.fid; 646 | if (ftype == Thrift.Type.STOP) { 647 | break; 648 | } 649 | switch (fid) 650 | { 651 | case 1: 652 | if (ftype == Thrift.Type.STRING) { 653 | this.type = input.readString(); 654 | } else { 655 | input.skip(ftype); 656 | } 657 | break; 658 | case 2: 659 | if (ftype == Thrift.Type.STRING) { 660 | this.version = input.readString(); 661 | } else { 662 | input.skip(ftype); 663 | } 664 | break; 665 | case 3: 666 | if (ftype == Thrift.Type.STRING) { 667 | this.langVersion = input.readString(); 668 | } else { 669 | input.skip(ftype); 670 | } 671 | break; 672 | default: 673 | input.skip(ftype); 674 | } 675 | input.readFieldEnd(); 676 | } 677 | input.readStructEnd(); 678 | return; 679 | }; 680 | 681 | Client.prototype.write = function(output) { 682 | output.writeStructBegin("Client"); 683 | if (this.type !== null && this.type !== undefined) { 684 | output.writeFieldBegin("type", Thrift.Type.STRING, 1); 685 | output.writeString(this.type); 686 | output.writeFieldEnd(); 687 | } 688 | if (this.version !== null && this.version !== undefined) { 689 | output.writeFieldBegin("version", Thrift.Type.STRING, 2); 690 | output.writeString(this.version); 691 | output.writeFieldEnd(); 692 | } 693 | if (this.langVersion !== null && this.langVersion !== undefined) { 694 | output.writeFieldBegin("langVersion", Thrift.Type.STRING, 3); 695 | output.writeString(this.langVersion); 696 | output.writeFieldEnd(); 697 | } 698 | output.writeFieldStop(); 699 | output.writeStructEnd(); 700 | return; 701 | }; 702 | 703 | let PacketInfo = module.exports.PacketInfo = function(args) { 704 | this.ver = null; 705 | this.sender = null; 706 | this.services = null; 707 | this.config = null; 708 | this.ipList = null; 709 | this.hostname = null; 710 | this.client = null; 711 | this.seq = null; 712 | if (args) { 713 | if (args.ver !== undefined && args.ver !== null) { 714 | this.ver = args.ver; 715 | } 716 | if (args.sender !== undefined && args.sender !== null) { 717 | this.sender = args.sender; 718 | } 719 | if (args.services !== undefined && args.services !== null) { 720 | this.services = args.services; 721 | } 722 | if (args.config !== undefined && args.config !== null) { 723 | this.config = args.config; 724 | } 725 | if (args.ipList !== undefined && args.ipList !== null) { 726 | this.ipList = Thrift.copyList(args.ipList, [null]); 727 | } 728 | if (args.hostname !== undefined && args.hostname !== null) { 729 | this.hostname = args.hostname; 730 | } 731 | if (args.client !== undefined && args.client !== null) { 732 | this.client = new ttypes.Client(args.client); 733 | } 734 | if (args.seq !== undefined && args.seq !== null) { 735 | this.seq = args.seq; 736 | } 737 | } 738 | }; 739 | PacketInfo.prototype = {}; 740 | PacketInfo.prototype.read = function(input) { 741 | input.readStructBegin(); 742 | while (true) 743 | { 744 | let ret = input.readFieldBegin(); 745 | let fname = ret.fname; 746 | let ftype = ret.ftype; 747 | let fid = ret.fid; 748 | if (ftype == Thrift.Type.STOP) { 749 | break; 750 | } 751 | switch (fid) 752 | { 753 | case 1: 754 | if (ftype == Thrift.Type.STRING) { 755 | this.ver = input.readString(); 756 | } else { 757 | input.skip(ftype); 758 | } 759 | break; 760 | case 2: 761 | if (ftype == Thrift.Type.STRING) { 762 | this.sender = input.readString(); 763 | } else { 764 | input.skip(ftype); 765 | } 766 | break; 767 | case 3: 768 | if (ftype == Thrift.Type.STRING) { 769 | this.services = input.readString(); 770 | } else { 771 | input.skip(ftype); 772 | } 773 | break; 774 | case 4: 775 | if (ftype == Thrift.Type.STRING) { 776 | this.config = input.readString(); 777 | } else { 778 | input.skip(ftype); 779 | } 780 | break; 781 | case 5: 782 | if (ftype == Thrift.Type.LIST) { 783 | let _size8 = 0; 784 | var _rtmp312; 785 | this.ipList = []; 786 | let _etype11 = 0; 787 | _rtmp312 = input.readListBegin(); 788 | _etype11 = _rtmp312.etype; 789 | _size8 = _rtmp312.size; 790 | for (let _i13 = 0; _i13 < _size8; ++_i13) 791 | { 792 | let elem14 = null; 793 | elem14 = input.readString(); 794 | this.ipList.push(elem14); 795 | } 796 | input.readListEnd(); 797 | } else { 798 | input.skip(ftype); 799 | } 800 | break; 801 | case 6: 802 | if (ftype == Thrift.Type.STRING) { 803 | this.hostname = input.readString(); 804 | } else { 805 | input.skip(ftype); 806 | } 807 | break; 808 | case 7: 809 | if (ftype == Thrift.Type.STRUCT) { 810 | this.client = new ttypes.Client(); 811 | this.client.read(input); 812 | } else { 813 | input.skip(ftype); 814 | } 815 | break; 816 | case 8: 817 | if (ftype == Thrift.Type.I32) { 818 | this.seq = input.readI32(); 819 | } else { 820 | input.skip(ftype); 821 | } 822 | break; 823 | default: 824 | input.skip(ftype); 825 | } 826 | input.readFieldEnd(); 827 | } 828 | input.readStructEnd(); 829 | return; 830 | }; 831 | 832 | PacketInfo.prototype.write = function(output) { 833 | output.writeStructBegin("PacketInfo"); 834 | if (this.ver !== null && this.ver !== undefined) { 835 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 836 | output.writeString(this.ver); 837 | output.writeFieldEnd(); 838 | } 839 | if (this.sender !== null && this.sender !== undefined) { 840 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 841 | output.writeString(this.sender); 842 | output.writeFieldEnd(); 843 | } 844 | if (this.services !== null && this.services !== undefined) { 845 | output.writeFieldBegin("services", Thrift.Type.STRING, 3); 846 | output.writeString(this.services); 847 | output.writeFieldEnd(); 848 | } 849 | if (this.config !== null && this.config !== undefined) { 850 | output.writeFieldBegin("config", Thrift.Type.STRING, 4); 851 | output.writeString(this.config); 852 | output.writeFieldEnd(); 853 | } 854 | if (this.ipList !== null && this.ipList !== undefined) { 855 | output.writeFieldBegin("ipList", Thrift.Type.LIST, 5); 856 | output.writeListBegin(Thrift.Type.STRING, this.ipList.length); 857 | for (let iter15 in this.ipList) 858 | { 859 | if (this.ipList.hasOwnProperty(iter15)) 860 | { 861 | iter15 = this.ipList[iter15]; 862 | output.writeString(iter15); 863 | } 864 | } 865 | output.writeListEnd(); 866 | output.writeFieldEnd(); 867 | } 868 | if (this.hostname !== null && this.hostname !== undefined) { 869 | output.writeFieldBegin("hostname", Thrift.Type.STRING, 6); 870 | output.writeString(this.hostname); 871 | output.writeFieldEnd(); 872 | } 873 | if (this.client !== null && this.client !== undefined) { 874 | output.writeFieldBegin("client", Thrift.Type.STRUCT, 7); 875 | this.client.write(output); 876 | output.writeFieldEnd(); 877 | } 878 | if (this.seq !== null && this.seq !== undefined) { 879 | output.writeFieldBegin("seq", Thrift.Type.I32, 8); 880 | output.writeI32(this.seq); 881 | output.writeFieldEnd(); 882 | } 883 | output.writeFieldStop(); 884 | output.writeStructEnd(); 885 | return; 886 | }; 887 | 888 | let PacketDisconnect = module.exports.PacketDisconnect = function(args) { 889 | this.ver = null; 890 | this.sender = null; 891 | if (args) { 892 | if (args.ver !== undefined && args.ver !== null) { 893 | this.ver = args.ver; 894 | } 895 | if (args.sender !== undefined && args.sender !== null) { 896 | this.sender = args.sender; 897 | } 898 | } 899 | }; 900 | PacketDisconnect.prototype = {}; 901 | PacketDisconnect.prototype.read = function(input) { 902 | input.readStructBegin(); 903 | while (true) 904 | { 905 | let ret = input.readFieldBegin(); 906 | let fname = ret.fname; 907 | let ftype = ret.ftype; 908 | let fid = ret.fid; 909 | if (ftype == Thrift.Type.STOP) { 910 | break; 911 | } 912 | switch (fid) 913 | { 914 | case 1: 915 | if (ftype == Thrift.Type.STRING) { 916 | this.ver = input.readString(); 917 | } else { 918 | input.skip(ftype); 919 | } 920 | break; 921 | case 2: 922 | if (ftype == Thrift.Type.STRING) { 923 | this.sender = input.readString(); 924 | } else { 925 | input.skip(ftype); 926 | } 927 | break; 928 | default: 929 | input.skip(ftype); 930 | } 931 | input.readFieldEnd(); 932 | } 933 | input.readStructEnd(); 934 | return; 935 | }; 936 | 937 | PacketDisconnect.prototype.write = function(output) { 938 | output.writeStructBegin("PacketDisconnect"); 939 | if (this.ver !== null && this.ver !== undefined) { 940 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 941 | output.writeString(this.ver); 942 | output.writeFieldEnd(); 943 | } 944 | if (this.sender !== null && this.sender !== undefined) { 945 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 946 | output.writeString(this.sender); 947 | output.writeFieldEnd(); 948 | } 949 | output.writeFieldStop(); 950 | output.writeStructEnd(); 951 | return; 952 | }; 953 | 954 | let PacketHeartbeat = module.exports.PacketHeartbeat = function(args) { 955 | this.ver = null; 956 | this.sender = null; 957 | this.cpu = null; 958 | if (args) { 959 | if (args.ver !== undefined && args.ver !== null) { 960 | this.ver = args.ver; 961 | } 962 | if (args.sender !== undefined && args.sender !== null) { 963 | this.sender = args.sender; 964 | } 965 | if (args.cpu !== undefined && args.cpu !== null) { 966 | this.cpu = args.cpu; 967 | } 968 | } 969 | }; 970 | PacketHeartbeat.prototype = {}; 971 | PacketHeartbeat.prototype.read = function(input) { 972 | input.readStructBegin(); 973 | while (true) 974 | { 975 | let ret = input.readFieldBegin(); 976 | let fname = ret.fname; 977 | let ftype = ret.ftype; 978 | let fid = ret.fid; 979 | if (ftype == Thrift.Type.STOP) { 980 | break; 981 | } 982 | switch (fid) 983 | { 984 | case 1: 985 | if (ftype == Thrift.Type.STRING) { 986 | this.ver = input.readString(); 987 | } else { 988 | input.skip(ftype); 989 | } 990 | break; 991 | case 2: 992 | if (ftype == Thrift.Type.STRING) { 993 | this.sender = input.readString(); 994 | } else { 995 | input.skip(ftype); 996 | } 997 | break; 998 | case 3: 999 | if (ftype == Thrift.Type.DOUBLE) { 1000 | this.cpu = input.readDouble(); 1001 | } else { 1002 | input.skip(ftype); 1003 | } 1004 | break; 1005 | default: 1006 | input.skip(ftype); 1007 | } 1008 | input.readFieldEnd(); 1009 | } 1010 | input.readStructEnd(); 1011 | return; 1012 | }; 1013 | 1014 | PacketHeartbeat.prototype.write = function(output) { 1015 | output.writeStructBegin("PacketHeartbeat"); 1016 | if (this.ver !== null && this.ver !== undefined) { 1017 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 1018 | output.writeString(this.ver); 1019 | output.writeFieldEnd(); 1020 | } 1021 | if (this.sender !== null && this.sender !== undefined) { 1022 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 1023 | output.writeString(this.sender); 1024 | output.writeFieldEnd(); 1025 | } 1026 | if (this.cpu !== null && this.cpu !== undefined) { 1027 | output.writeFieldBegin("cpu", Thrift.Type.DOUBLE, 3); 1028 | output.writeDouble(this.cpu); 1029 | output.writeFieldEnd(); 1030 | } 1031 | output.writeFieldStop(); 1032 | output.writeStructEnd(); 1033 | return; 1034 | }; 1035 | 1036 | let PacketPing = module.exports.PacketPing = function(args) { 1037 | this.ver = null; 1038 | this.sender = null; 1039 | this.time = null; 1040 | if (args) { 1041 | if (args.ver !== undefined && args.ver !== null) { 1042 | this.ver = args.ver; 1043 | } 1044 | if (args.sender !== undefined && args.sender !== null) { 1045 | this.sender = args.sender; 1046 | } 1047 | if (args.time !== undefined && args.time !== null) { 1048 | this.time = args.time; 1049 | } 1050 | } 1051 | }; 1052 | PacketPing.prototype = {}; 1053 | PacketPing.prototype.read = function(input) { 1054 | input.readStructBegin(); 1055 | while (true) 1056 | { 1057 | let ret = input.readFieldBegin(); 1058 | let fname = ret.fname; 1059 | let ftype = ret.ftype; 1060 | let fid = ret.fid; 1061 | if (ftype == Thrift.Type.STOP) { 1062 | break; 1063 | } 1064 | switch (fid) 1065 | { 1066 | case 1: 1067 | if (ftype == Thrift.Type.STRING) { 1068 | this.ver = input.readString(); 1069 | } else { 1070 | input.skip(ftype); 1071 | } 1072 | break; 1073 | case 2: 1074 | if (ftype == Thrift.Type.STRING) { 1075 | this.sender = input.readString(); 1076 | } else { 1077 | input.skip(ftype); 1078 | } 1079 | break; 1080 | case 3: 1081 | if (ftype == Thrift.Type.I64) { 1082 | this.time = input.readI64(); 1083 | } else { 1084 | input.skip(ftype); 1085 | } 1086 | break; 1087 | default: 1088 | input.skip(ftype); 1089 | } 1090 | input.readFieldEnd(); 1091 | } 1092 | input.readStructEnd(); 1093 | return; 1094 | }; 1095 | 1096 | PacketPing.prototype.write = function(output) { 1097 | output.writeStructBegin("PacketPing"); 1098 | if (this.ver !== null && this.ver !== undefined) { 1099 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 1100 | output.writeString(this.ver); 1101 | output.writeFieldEnd(); 1102 | } 1103 | if (this.sender !== null && this.sender !== undefined) { 1104 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 1105 | output.writeString(this.sender); 1106 | output.writeFieldEnd(); 1107 | } 1108 | if (this.time !== null && this.time !== undefined) { 1109 | output.writeFieldBegin("time", Thrift.Type.I64, 3); 1110 | output.writeI64(this.time); 1111 | output.writeFieldEnd(); 1112 | } 1113 | output.writeFieldStop(); 1114 | output.writeStructEnd(); 1115 | return; 1116 | }; 1117 | 1118 | let PacketPong = module.exports.PacketPong = function(args) { 1119 | this.ver = null; 1120 | this.sender = null; 1121 | this.time = null; 1122 | this.arrived = null; 1123 | if (args) { 1124 | if (args.ver !== undefined && args.ver !== null) { 1125 | this.ver = args.ver; 1126 | } 1127 | if (args.sender !== undefined && args.sender !== null) { 1128 | this.sender = args.sender; 1129 | } 1130 | if (args.time !== undefined && args.time !== null) { 1131 | this.time = args.time; 1132 | } 1133 | if (args.arrived !== undefined && args.arrived !== null) { 1134 | this.arrived = args.arrived; 1135 | } 1136 | } 1137 | }; 1138 | PacketPong.prototype = {}; 1139 | PacketPong.prototype.read = function(input) { 1140 | input.readStructBegin(); 1141 | while (true) 1142 | { 1143 | let ret = input.readFieldBegin(); 1144 | let fname = ret.fname; 1145 | let ftype = ret.ftype; 1146 | let fid = ret.fid; 1147 | if (ftype == Thrift.Type.STOP) { 1148 | break; 1149 | } 1150 | switch (fid) 1151 | { 1152 | case 1: 1153 | if (ftype == Thrift.Type.STRING) { 1154 | this.ver = input.readString(); 1155 | } else { 1156 | input.skip(ftype); 1157 | } 1158 | break; 1159 | case 2: 1160 | if (ftype == Thrift.Type.STRING) { 1161 | this.sender = input.readString(); 1162 | } else { 1163 | input.skip(ftype); 1164 | } 1165 | break; 1166 | case 3: 1167 | if (ftype == Thrift.Type.I64) { 1168 | this.time = input.readI64(); 1169 | } else { 1170 | input.skip(ftype); 1171 | } 1172 | break; 1173 | case 4: 1174 | if (ftype == Thrift.Type.I64) { 1175 | this.arrived = input.readI64(); 1176 | } else { 1177 | input.skip(ftype); 1178 | } 1179 | break; 1180 | default: 1181 | input.skip(ftype); 1182 | } 1183 | input.readFieldEnd(); 1184 | } 1185 | input.readStructEnd(); 1186 | return; 1187 | }; 1188 | 1189 | PacketPong.prototype.write = function(output) { 1190 | output.writeStructBegin("PacketPong"); 1191 | if (this.ver !== null && this.ver !== undefined) { 1192 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 1193 | output.writeString(this.ver); 1194 | output.writeFieldEnd(); 1195 | } 1196 | if (this.sender !== null && this.sender !== undefined) { 1197 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 1198 | output.writeString(this.sender); 1199 | output.writeFieldEnd(); 1200 | } 1201 | if (this.time !== null && this.time !== undefined) { 1202 | output.writeFieldBegin("time", Thrift.Type.I64, 3); 1203 | output.writeI64(this.time); 1204 | output.writeFieldEnd(); 1205 | } 1206 | if (this.arrived !== null && this.arrived !== undefined) { 1207 | output.writeFieldBegin("arrived", Thrift.Type.I64, 4); 1208 | output.writeI64(this.arrived); 1209 | output.writeFieldEnd(); 1210 | } 1211 | output.writeFieldStop(); 1212 | output.writeStructEnd(); 1213 | return; 1214 | }; 1215 | 1216 | let PacketGossipHello = module.exports.PacketGossipHello = function(args) { 1217 | this.ver = null; 1218 | this.sender = null; 1219 | this.host = null; 1220 | this.port = null; 1221 | if (args) { 1222 | if (args.ver !== undefined && args.ver !== null) { 1223 | this.ver = args.ver; 1224 | } 1225 | if (args.sender !== undefined && args.sender !== null) { 1226 | this.sender = args.sender; 1227 | } 1228 | if (args.host !== undefined && args.host !== null) { 1229 | this.host = args.host; 1230 | } 1231 | if (args.port !== undefined && args.port !== null) { 1232 | this.port = args.port; 1233 | } 1234 | } 1235 | }; 1236 | PacketGossipHello.prototype = {}; 1237 | PacketGossipHello.prototype.read = function(input) { 1238 | input.readStructBegin(); 1239 | while (true) 1240 | { 1241 | let ret = input.readFieldBegin(); 1242 | let fname = ret.fname; 1243 | let ftype = ret.ftype; 1244 | let fid = ret.fid; 1245 | if (ftype == Thrift.Type.STOP) { 1246 | break; 1247 | } 1248 | switch (fid) 1249 | { 1250 | case 1: 1251 | if (ftype == Thrift.Type.STRING) { 1252 | this.ver = input.readString(); 1253 | } else { 1254 | input.skip(ftype); 1255 | } 1256 | break; 1257 | case 2: 1258 | if (ftype == Thrift.Type.STRING) { 1259 | this.sender = input.readString(); 1260 | } else { 1261 | input.skip(ftype); 1262 | } 1263 | break; 1264 | case 3: 1265 | if (ftype == Thrift.Type.STRING) { 1266 | this.host = input.readString(); 1267 | } else { 1268 | input.skip(ftype); 1269 | } 1270 | break; 1271 | case 4: 1272 | if (ftype == Thrift.Type.I32) { 1273 | this.port = input.readI32(); 1274 | } else { 1275 | input.skip(ftype); 1276 | } 1277 | break; 1278 | default: 1279 | input.skip(ftype); 1280 | } 1281 | input.readFieldEnd(); 1282 | } 1283 | input.readStructEnd(); 1284 | return; 1285 | }; 1286 | 1287 | PacketGossipHello.prototype.write = function(output) { 1288 | output.writeStructBegin("PacketGossipHello"); 1289 | if (this.ver !== null && this.ver !== undefined) { 1290 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 1291 | output.writeString(this.ver); 1292 | output.writeFieldEnd(); 1293 | } 1294 | if (this.sender !== null && this.sender !== undefined) { 1295 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 1296 | output.writeString(this.sender); 1297 | output.writeFieldEnd(); 1298 | } 1299 | if (this.host !== null && this.host !== undefined) { 1300 | output.writeFieldBegin("host", Thrift.Type.STRING, 3); 1301 | output.writeString(this.host); 1302 | output.writeFieldEnd(); 1303 | } 1304 | if (this.port !== null && this.port !== undefined) { 1305 | output.writeFieldBegin("port", Thrift.Type.I32, 4); 1306 | output.writeI32(this.port); 1307 | output.writeFieldEnd(); 1308 | } 1309 | output.writeFieldStop(); 1310 | output.writeStructEnd(); 1311 | return; 1312 | }; 1313 | 1314 | let PacketGossipRequest = module.exports.PacketGossipRequest = function(args) { 1315 | this.ver = null; 1316 | this.sender = null; 1317 | this.online = null; 1318 | this.offline = null; 1319 | if (args) { 1320 | if (args.ver !== undefined && args.ver !== null) { 1321 | this.ver = args.ver; 1322 | } 1323 | if (args.sender !== undefined && args.sender !== null) { 1324 | this.sender = args.sender; 1325 | } 1326 | if (args.online !== undefined && args.online !== null) { 1327 | this.online = args.online; 1328 | } 1329 | if (args.offline !== undefined && args.offline !== null) { 1330 | this.offline = args.offline; 1331 | } 1332 | } 1333 | }; 1334 | PacketGossipRequest.prototype = {}; 1335 | PacketGossipRequest.prototype.read = function(input) { 1336 | input.readStructBegin(); 1337 | while (true) 1338 | { 1339 | let ret = input.readFieldBegin(); 1340 | let fname = ret.fname; 1341 | let ftype = ret.ftype; 1342 | let fid = ret.fid; 1343 | if (ftype == Thrift.Type.STOP) { 1344 | break; 1345 | } 1346 | switch (fid) 1347 | { 1348 | case 1: 1349 | if (ftype == Thrift.Type.STRING) { 1350 | this.ver = input.readString(); 1351 | } else { 1352 | input.skip(ftype); 1353 | } 1354 | break; 1355 | case 2: 1356 | if (ftype == Thrift.Type.STRING) { 1357 | this.sender = input.readString(); 1358 | } else { 1359 | input.skip(ftype); 1360 | } 1361 | break; 1362 | case 3: 1363 | if (ftype == Thrift.Type.STRING) { 1364 | this.online = input.readString(); 1365 | } else { 1366 | input.skip(ftype); 1367 | } 1368 | break; 1369 | case 4: 1370 | if (ftype == Thrift.Type.STRING) { 1371 | this.offline = input.readString(); 1372 | } else { 1373 | input.skip(ftype); 1374 | } 1375 | break; 1376 | default: 1377 | input.skip(ftype); 1378 | } 1379 | input.readFieldEnd(); 1380 | } 1381 | input.readStructEnd(); 1382 | return; 1383 | }; 1384 | 1385 | PacketGossipRequest.prototype.write = function(output) { 1386 | output.writeStructBegin("PacketGossipRequest"); 1387 | if (this.ver !== null && this.ver !== undefined) { 1388 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 1389 | output.writeString(this.ver); 1390 | output.writeFieldEnd(); 1391 | } 1392 | if (this.sender !== null && this.sender !== undefined) { 1393 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 1394 | output.writeString(this.sender); 1395 | output.writeFieldEnd(); 1396 | } 1397 | if (this.online !== null && this.online !== undefined) { 1398 | output.writeFieldBegin("online", Thrift.Type.STRING, 3); 1399 | output.writeString(this.online); 1400 | output.writeFieldEnd(); 1401 | } 1402 | if (this.offline !== null && this.offline !== undefined) { 1403 | output.writeFieldBegin("offline", Thrift.Type.STRING, 4); 1404 | output.writeString(this.offline); 1405 | output.writeFieldEnd(); 1406 | } 1407 | output.writeFieldStop(); 1408 | output.writeStructEnd(); 1409 | return; 1410 | }; 1411 | 1412 | let PacketGossipResponse = module.exports.PacketGossipResponse = function(args) { 1413 | this.ver = null; 1414 | this.sender = null; 1415 | this.online = null; 1416 | this.offline = null; 1417 | if (args) { 1418 | if (args.ver !== undefined && args.ver !== null) { 1419 | this.ver = args.ver; 1420 | } 1421 | if (args.sender !== undefined && args.sender !== null) { 1422 | this.sender = args.sender; 1423 | } 1424 | if (args.online !== undefined && args.online !== null) { 1425 | this.online = args.online; 1426 | } 1427 | if (args.offline !== undefined && args.offline !== null) { 1428 | this.offline = args.offline; 1429 | } 1430 | } 1431 | }; 1432 | PacketGossipResponse.prototype = {}; 1433 | PacketGossipResponse.prototype.read = function(input) { 1434 | input.readStructBegin(); 1435 | while (true) 1436 | { 1437 | let ret = input.readFieldBegin(); 1438 | let fname = ret.fname; 1439 | let ftype = ret.ftype; 1440 | let fid = ret.fid; 1441 | if (ftype == Thrift.Type.STOP) { 1442 | break; 1443 | } 1444 | switch (fid) 1445 | { 1446 | case 1: 1447 | if (ftype == Thrift.Type.STRING) { 1448 | this.ver = input.readString(); 1449 | } else { 1450 | input.skip(ftype); 1451 | } 1452 | break; 1453 | case 2: 1454 | if (ftype == Thrift.Type.STRING) { 1455 | this.sender = input.readString(); 1456 | } else { 1457 | input.skip(ftype); 1458 | } 1459 | break; 1460 | case 3: 1461 | if (ftype == Thrift.Type.STRING) { 1462 | this.online = input.readString(); 1463 | } else { 1464 | input.skip(ftype); 1465 | } 1466 | break; 1467 | case 4: 1468 | if (ftype == Thrift.Type.STRING) { 1469 | this.offline = input.readString(); 1470 | } else { 1471 | input.skip(ftype); 1472 | } 1473 | break; 1474 | default: 1475 | input.skip(ftype); 1476 | } 1477 | input.readFieldEnd(); 1478 | } 1479 | input.readStructEnd(); 1480 | return; 1481 | }; 1482 | 1483 | PacketGossipResponse.prototype.write = function(output) { 1484 | output.writeStructBegin("PacketGossipResponse"); 1485 | if (this.ver !== null && this.ver !== undefined) { 1486 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 1487 | output.writeString(this.ver); 1488 | output.writeFieldEnd(); 1489 | } 1490 | if (this.sender !== null && this.sender !== undefined) { 1491 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 1492 | output.writeString(this.sender); 1493 | output.writeFieldEnd(); 1494 | } 1495 | if (this.online !== null && this.online !== undefined) { 1496 | output.writeFieldBegin("online", Thrift.Type.STRING, 3); 1497 | output.writeString(this.online); 1498 | output.writeFieldEnd(); 1499 | } 1500 | if (this.offline !== null && this.offline !== undefined) { 1501 | output.writeFieldBegin("offline", Thrift.Type.STRING, 4); 1502 | output.writeString(this.offline); 1503 | output.writeFieldEnd(); 1504 | } 1505 | output.writeFieldStop(); 1506 | output.writeStructEnd(); 1507 | return; 1508 | }; 1509 | 1510 | -------------------------------------------------------------------------------- /4.0/thrift/gen-nodejs/packets_types.js: -------------------------------------------------------------------------------- 1 | // 2 | // Autogenerated by Thrift Compiler (0.12.0) 3 | // 4 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING 5 | // 6 | "use strict"; 7 | 8 | let thrift = require("thrift"); 9 | let Thrift = thrift.Thrift; 10 | let Q = thrift.Q; 11 | 12 | 13 | let ttypes = module.exports = {}; 14 | ttypes.DataType = { 15 | "DATATYPE_UNDEFINED" : 0, 16 | "DATATYPE_NULL" : 1, 17 | "DATATYPE_JSON" : 2, 18 | "DATATYPE_BUFFER" : 3 19 | }; 20 | let PacketEvent = module.exports.PacketEvent = function(args) { 21 | this.ver = null; 22 | this.sender = null; 23 | this.id = null; 24 | this.event = null; 25 | this.data = null; 26 | this.dataType = null; 27 | this.groups = null; 28 | this.broadcast = null; 29 | this.meta = null; 30 | this.level = null; 31 | this.tracing = null; 32 | this.parentID = null; 33 | this.requestID = null; 34 | this.stream = null; 35 | this.seq = null; 36 | this.caller = null; 37 | this.needAck = null; 38 | if (args) { 39 | if (args.ver !== undefined && args.ver !== null) { 40 | this.ver = args.ver; 41 | } 42 | if (args.sender !== undefined && args.sender !== null) { 43 | this.sender = args.sender; 44 | } 45 | if (args.id !== undefined && args.id !== null) { 46 | this.id = args.id; 47 | } 48 | if (args.event !== undefined && args.event !== null) { 49 | this.event = args.event; 50 | } 51 | if (args.data !== undefined && args.data !== null) { 52 | this.data = args.data; 53 | } 54 | if (args.dataType !== undefined && args.dataType !== null) { 55 | this.dataType = args.dataType; 56 | } 57 | if (args.groups !== undefined && args.groups !== null) { 58 | this.groups = Thrift.copyList(args.groups, [null]); 59 | } 60 | if (args.broadcast !== undefined && args.broadcast !== null) { 61 | this.broadcast = args.broadcast; 62 | } 63 | if (args.meta !== undefined && args.meta !== null) { 64 | this.meta = args.meta; 65 | } 66 | if (args.level !== undefined && args.level !== null) { 67 | this.level = args.level; 68 | } 69 | if (args.tracing !== undefined && args.tracing !== null) { 70 | this.tracing = args.tracing; 71 | } 72 | if (args.parentID !== undefined && args.parentID !== null) { 73 | this.parentID = args.parentID; 74 | } 75 | if (args.requestID !== undefined && args.requestID !== null) { 76 | this.requestID = args.requestID; 77 | } 78 | if (args.stream !== undefined && args.stream !== null) { 79 | this.stream = args.stream; 80 | } 81 | if (args.seq !== undefined && args.seq !== null) { 82 | this.seq = args.seq; 83 | } 84 | if (args.caller !== undefined && args.caller !== null) { 85 | this.caller = args.caller; 86 | } 87 | if (args.needAck !== undefined && args.needAck !== null) { 88 | this.needAck = args.needAck; 89 | } 90 | } 91 | }; 92 | PacketEvent.prototype = {}; 93 | PacketEvent.prototype.read = function(input) { 94 | input.readStructBegin(); 95 | while (true) { 96 | let ret = input.readFieldBegin(); 97 | let ftype = ret.ftype; 98 | let fid = ret.fid; 99 | if (ftype == Thrift.Type.STOP) { 100 | break; 101 | } 102 | switch (fid) { 103 | case 1: 104 | if (ftype == Thrift.Type.STRING) { 105 | this.ver = input.readString(); 106 | } else { 107 | input.skip(ftype); 108 | } 109 | break; 110 | case 2: 111 | if (ftype == Thrift.Type.STRING) { 112 | this.sender = input.readString(); 113 | } else { 114 | input.skip(ftype); 115 | } 116 | break; 117 | case 3: 118 | if (ftype == Thrift.Type.STRING) { 119 | this.id = input.readString(); 120 | } else { 121 | input.skip(ftype); 122 | } 123 | break; 124 | case 4: 125 | if (ftype == Thrift.Type.STRING) { 126 | this.event = input.readString(); 127 | } else { 128 | input.skip(ftype); 129 | } 130 | break; 131 | case 5: 132 | if (ftype == Thrift.Type.STRING) { 133 | this.data = input.readBinary(); 134 | } else { 135 | input.skip(ftype); 136 | } 137 | break; 138 | case 6: 139 | if (ftype == Thrift.Type.I32) { 140 | this.dataType = input.readI32(); 141 | } else { 142 | input.skip(ftype); 143 | } 144 | break; 145 | case 7: 146 | if (ftype == Thrift.Type.LIST) { 147 | this.groups = []; 148 | let _rtmp31 = input.readListBegin(); 149 | let _size0 = _rtmp31.size || 0; 150 | for (let _i2 = 0; _i2 < _size0; ++_i2) { 151 | let elem3 = null; 152 | elem3 = input.readString(); 153 | this.groups.push(elem3); 154 | } 155 | input.readListEnd(); 156 | } else { 157 | input.skip(ftype); 158 | } 159 | break; 160 | case 8: 161 | if (ftype == Thrift.Type.BOOL) { 162 | this.broadcast = input.readBool(); 163 | } else { 164 | input.skip(ftype); 165 | } 166 | break; 167 | case 9: 168 | if (ftype == Thrift.Type.STRING) { 169 | this.meta = input.readString(); 170 | } else { 171 | input.skip(ftype); 172 | } 173 | break; 174 | case 10: 175 | if (ftype == Thrift.Type.I32) { 176 | this.level = input.readI32(); 177 | } else { 178 | input.skip(ftype); 179 | } 180 | break; 181 | case 11: 182 | if (ftype == Thrift.Type.BOOL) { 183 | this.tracing = input.readBool(); 184 | } else { 185 | input.skip(ftype); 186 | } 187 | break; 188 | case 12: 189 | if (ftype == Thrift.Type.STRING) { 190 | this.parentID = input.readString(); 191 | } else { 192 | input.skip(ftype); 193 | } 194 | break; 195 | case 13: 196 | if (ftype == Thrift.Type.STRING) { 197 | this.requestID = input.readString(); 198 | } else { 199 | input.skip(ftype); 200 | } 201 | break; 202 | case 14: 203 | if (ftype == Thrift.Type.BOOL) { 204 | this.stream = input.readBool(); 205 | } else { 206 | input.skip(ftype); 207 | } 208 | break; 209 | case 15: 210 | if (ftype == Thrift.Type.I32) { 211 | this.seq = input.readI32(); 212 | } else { 213 | input.skip(ftype); 214 | } 215 | break; 216 | case 16: 217 | if (ftype == Thrift.Type.STRING) { 218 | this.caller = input.readString(); 219 | } else { 220 | input.skip(ftype); 221 | } 222 | break; 223 | case 17: 224 | if (ftype == Thrift.Type.BOOL) { 225 | this.needAck = input.readBool(); 226 | } else { 227 | input.skip(ftype); 228 | } 229 | break; 230 | default: 231 | input.skip(ftype); 232 | } 233 | input.readFieldEnd(); 234 | } 235 | input.readStructEnd(); 236 | return; 237 | }; 238 | 239 | PacketEvent.prototype.write = function(output) { 240 | output.writeStructBegin("PacketEvent"); 241 | if (this.ver !== null && this.ver !== undefined) { 242 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 243 | output.writeString(this.ver); 244 | output.writeFieldEnd(); 245 | } 246 | if (this.sender !== null && this.sender !== undefined) { 247 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 248 | output.writeString(this.sender); 249 | output.writeFieldEnd(); 250 | } 251 | if (this.id !== null && this.id !== undefined) { 252 | output.writeFieldBegin("id", Thrift.Type.STRING, 3); 253 | output.writeString(this.id); 254 | output.writeFieldEnd(); 255 | } 256 | if (this.event !== null && this.event !== undefined) { 257 | output.writeFieldBegin("event", Thrift.Type.STRING, 4); 258 | output.writeString(this.event); 259 | output.writeFieldEnd(); 260 | } 261 | if (this.data !== null && this.data !== undefined) { 262 | output.writeFieldBegin("data", Thrift.Type.STRING, 5); 263 | output.writeBinary(this.data); 264 | output.writeFieldEnd(); 265 | } 266 | if (this.dataType !== null && this.dataType !== undefined) { 267 | output.writeFieldBegin("dataType", Thrift.Type.I32, 6); 268 | output.writeI32(this.dataType); 269 | output.writeFieldEnd(); 270 | } 271 | if (this.groups !== null && this.groups !== undefined) { 272 | output.writeFieldBegin("groups", Thrift.Type.LIST, 7); 273 | output.writeListBegin(Thrift.Type.STRING, this.groups.length); 274 | for (let iter4 in this.groups) { 275 | if (this.groups.hasOwnProperty(iter4)) { 276 | iter4 = this.groups[iter4]; 277 | output.writeString(iter4); 278 | } 279 | } 280 | output.writeListEnd(); 281 | output.writeFieldEnd(); 282 | } 283 | if (this.broadcast !== null && this.broadcast !== undefined) { 284 | output.writeFieldBegin("broadcast", Thrift.Type.BOOL, 8); 285 | output.writeBool(this.broadcast); 286 | output.writeFieldEnd(); 287 | } 288 | if (this.meta !== null && this.meta !== undefined) { 289 | output.writeFieldBegin("meta", Thrift.Type.STRING, 9); 290 | output.writeString(this.meta); 291 | output.writeFieldEnd(); 292 | } 293 | if (this.level !== null && this.level !== undefined) { 294 | output.writeFieldBegin("level", Thrift.Type.I32, 10); 295 | output.writeI32(this.level); 296 | output.writeFieldEnd(); 297 | } 298 | if (this.tracing !== null && this.tracing !== undefined) { 299 | output.writeFieldBegin("tracing", Thrift.Type.BOOL, 11); 300 | output.writeBool(this.tracing); 301 | output.writeFieldEnd(); 302 | } 303 | if (this.parentID !== null && this.parentID !== undefined) { 304 | output.writeFieldBegin("parentID", Thrift.Type.STRING, 12); 305 | output.writeString(this.parentID); 306 | output.writeFieldEnd(); 307 | } 308 | if (this.requestID !== null && this.requestID !== undefined) { 309 | output.writeFieldBegin("requestID", Thrift.Type.STRING, 13); 310 | output.writeString(this.requestID); 311 | output.writeFieldEnd(); 312 | } 313 | if (this.stream !== null && this.stream !== undefined) { 314 | output.writeFieldBegin("stream", Thrift.Type.BOOL, 14); 315 | output.writeBool(this.stream); 316 | output.writeFieldEnd(); 317 | } 318 | if (this.seq !== null && this.seq !== undefined) { 319 | output.writeFieldBegin("seq", Thrift.Type.I32, 15); 320 | output.writeI32(this.seq); 321 | output.writeFieldEnd(); 322 | } 323 | if (this.caller !== null && this.caller !== undefined) { 324 | output.writeFieldBegin("caller", Thrift.Type.STRING, 16); 325 | output.writeString(this.caller); 326 | output.writeFieldEnd(); 327 | } 328 | if (this.needAck !== null && this.needAck !== undefined) { 329 | output.writeFieldBegin("needAck", Thrift.Type.BOOL, 17); 330 | output.writeBool(this.needAck); 331 | output.writeFieldEnd(); 332 | } 333 | output.writeFieldStop(); 334 | output.writeStructEnd(); 335 | return; 336 | }; 337 | 338 | let PacketRequest = module.exports.PacketRequest = function(args) { 339 | this.ver = null; 340 | this.sender = null; 341 | this.id = null; 342 | this.action = null; 343 | this.params = null; 344 | this.paramsType = null; 345 | this.meta = null; 346 | this.timeout = null; 347 | this.level = null; 348 | this.tracing = null; 349 | this.parentID = null; 350 | this.requestID = null; 351 | this.stream = null; 352 | this.seq = null; 353 | this.caller = null; 354 | if (args) { 355 | if (args.ver !== undefined && args.ver !== null) { 356 | this.ver = args.ver; 357 | } 358 | if (args.sender !== undefined && args.sender !== null) { 359 | this.sender = args.sender; 360 | } 361 | if (args.id !== undefined && args.id !== null) { 362 | this.id = args.id; 363 | } 364 | if (args.action !== undefined && args.action !== null) { 365 | this.action = args.action; 366 | } 367 | if (args.params !== undefined && args.params !== null) { 368 | this.params = args.params; 369 | } 370 | if (args.paramsType !== undefined && args.paramsType !== null) { 371 | this.paramsType = args.paramsType; 372 | } 373 | if (args.meta !== undefined && args.meta !== null) { 374 | this.meta = args.meta; 375 | } 376 | if (args.timeout !== undefined && args.timeout !== null) { 377 | this.timeout = args.timeout; 378 | } 379 | if (args.level !== undefined && args.level !== null) { 380 | this.level = args.level; 381 | } 382 | if (args.tracing !== undefined && args.tracing !== null) { 383 | this.tracing = args.tracing; 384 | } 385 | if (args.parentID !== undefined && args.parentID !== null) { 386 | this.parentID = args.parentID; 387 | } 388 | if (args.requestID !== undefined && args.requestID !== null) { 389 | this.requestID = args.requestID; 390 | } 391 | if (args.stream !== undefined && args.stream !== null) { 392 | this.stream = args.stream; 393 | } 394 | if (args.seq !== undefined && args.seq !== null) { 395 | this.seq = args.seq; 396 | } 397 | if (args.caller !== undefined && args.caller !== null) { 398 | this.caller = args.caller; 399 | } 400 | } 401 | }; 402 | PacketRequest.prototype = {}; 403 | PacketRequest.prototype.read = function(input) { 404 | input.readStructBegin(); 405 | while (true) { 406 | let ret = input.readFieldBegin(); 407 | let ftype = ret.ftype; 408 | let fid = ret.fid; 409 | if (ftype == Thrift.Type.STOP) { 410 | break; 411 | } 412 | switch (fid) { 413 | case 1: 414 | if (ftype == Thrift.Type.STRING) { 415 | this.ver = input.readString(); 416 | } else { 417 | input.skip(ftype); 418 | } 419 | break; 420 | case 2: 421 | if (ftype == Thrift.Type.STRING) { 422 | this.sender = input.readString(); 423 | } else { 424 | input.skip(ftype); 425 | } 426 | break; 427 | case 3: 428 | if (ftype == Thrift.Type.STRING) { 429 | this.id = input.readString(); 430 | } else { 431 | input.skip(ftype); 432 | } 433 | break; 434 | case 4: 435 | if (ftype == Thrift.Type.STRING) { 436 | this.action = input.readString(); 437 | } else { 438 | input.skip(ftype); 439 | } 440 | break; 441 | case 5: 442 | if (ftype == Thrift.Type.STRING) { 443 | this.params = input.readBinary(); 444 | } else { 445 | input.skip(ftype); 446 | } 447 | break; 448 | case 6: 449 | if (ftype == Thrift.Type.I32) { 450 | this.paramsType = input.readI32(); 451 | } else { 452 | input.skip(ftype); 453 | } 454 | break; 455 | case 7: 456 | if (ftype == Thrift.Type.STRING) { 457 | this.meta = input.readString(); 458 | } else { 459 | input.skip(ftype); 460 | } 461 | break; 462 | case 8: 463 | if (ftype == Thrift.Type.DOUBLE) { 464 | this.timeout = input.readDouble(); 465 | } else { 466 | input.skip(ftype); 467 | } 468 | break; 469 | case 9: 470 | if (ftype == Thrift.Type.I32) { 471 | this.level = input.readI32(); 472 | } else { 473 | input.skip(ftype); 474 | } 475 | break; 476 | case 10: 477 | if (ftype == Thrift.Type.BOOL) { 478 | this.tracing = input.readBool(); 479 | } else { 480 | input.skip(ftype); 481 | } 482 | break; 483 | case 11: 484 | if (ftype == Thrift.Type.STRING) { 485 | this.parentID = input.readString(); 486 | } else { 487 | input.skip(ftype); 488 | } 489 | break; 490 | case 12: 491 | if (ftype == Thrift.Type.STRING) { 492 | this.requestID = input.readString(); 493 | } else { 494 | input.skip(ftype); 495 | } 496 | break; 497 | case 13: 498 | if (ftype == Thrift.Type.BOOL) { 499 | this.stream = input.readBool(); 500 | } else { 501 | input.skip(ftype); 502 | } 503 | break; 504 | case 14: 505 | if (ftype == Thrift.Type.I32) { 506 | this.seq = input.readI32(); 507 | } else { 508 | input.skip(ftype); 509 | } 510 | break; 511 | case 15: 512 | if (ftype == Thrift.Type.STRING) { 513 | this.caller = input.readString(); 514 | } else { 515 | input.skip(ftype); 516 | } 517 | break; 518 | default: 519 | input.skip(ftype); 520 | } 521 | input.readFieldEnd(); 522 | } 523 | input.readStructEnd(); 524 | return; 525 | }; 526 | 527 | PacketRequest.prototype.write = function(output) { 528 | output.writeStructBegin("PacketRequest"); 529 | if (this.ver !== null && this.ver !== undefined) { 530 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 531 | output.writeString(this.ver); 532 | output.writeFieldEnd(); 533 | } 534 | if (this.sender !== null && this.sender !== undefined) { 535 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 536 | output.writeString(this.sender); 537 | output.writeFieldEnd(); 538 | } 539 | if (this.id !== null && this.id !== undefined) { 540 | output.writeFieldBegin("id", Thrift.Type.STRING, 3); 541 | output.writeString(this.id); 542 | output.writeFieldEnd(); 543 | } 544 | if (this.action !== null && this.action !== undefined) { 545 | output.writeFieldBegin("action", Thrift.Type.STRING, 4); 546 | output.writeString(this.action); 547 | output.writeFieldEnd(); 548 | } 549 | if (this.params !== null && this.params !== undefined) { 550 | output.writeFieldBegin("params", Thrift.Type.STRING, 5); 551 | output.writeBinary(this.params); 552 | output.writeFieldEnd(); 553 | } 554 | if (this.paramsType !== null && this.paramsType !== undefined) { 555 | output.writeFieldBegin("paramsType", Thrift.Type.I32, 6); 556 | output.writeI32(this.paramsType); 557 | output.writeFieldEnd(); 558 | } 559 | if (this.meta !== null && this.meta !== undefined) { 560 | output.writeFieldBegin("meta", Thrift.Type.STRING, 7); 561 | output.writeString(this.meta); 562 | output.writeFieldEnd(); 563 | } 564 | if (this.timeout !== null && this.timeout !== undefined) { 565 | output.writeFieldBegin("timeout", Thrift.Type.DOUBLE, 8); 566 | output.writeDouble(this.timeout); 567 | output.writeFieldEnd(); 568 | } 569 | if (this.level !== null && this.level !== undefined) { 570 | output.writeFieldBegin("level", Thrift.Type.I32, 9); 571 | output.writeI32(this.level); 572 | output.writeFieldEnd(); 573 | } 574 | if (this.tracing !== null && this.tracing !== undefined) { 575 | output.writeFieldBegin("tracing", Thrift.Type.BOOL, 10); 576 | output.writeBool(this.tracing); 577 | output.writeFieldEnd(); 578 | } 579 | if (this.parentID !== null && this.parentID !== undefined) { 580 | output.writeFieldBegin("parentID", Thrift.Type.STRING, 11); 581 | output.writeString(this.parentID); 582 | output.writeFieldEnd(); 583 | } 584 | if (this.requestID !== null && this.requestID !== undefined) { 585 | output.writeFieldBegin("requestID", Thrift.Type.STRING, 12); 586 | output.writeString(this.requestID); 587 | output.writeFieldEnd(); 588 | } 589 | if (this.stream !== null && this.stream !== undefined) { 590 | output.writeFieldBegin("stream", Thrift.Type.BOOL, 13); 591 | output.writeBool(this.stream); 592 | output.writeFieldEnd(); 593 | } 594 | if (this.seq !== null && this.seq !== undefined) { 595 | output.writeFieldBegin("seq", Thrift.Type.I32, 14); 596 | output.writeI32(this.seq); 597 | output.writeFieldEnd(); 598 | } 599 | if (this.caller !== null && this.caller !== undefined) { 600 | output.writeFieldBegin("caller", Thrift.Type.STRING, 15); 601 | output.writeString(this.caller); 602 | output.writeFieldEnd(); 603 | } 604 | output.writeFieldStop(); 605 | output.writeStructEnd(); 606 | return; 607 | }; 608 | 609 | let PacketResponse = module.exports.PacketResponse = function(args) { 610 | this.ver = null; 611 | this.sender = null; 612 | this.id = null; 613 | this.success = null; 614 | this.data = null; 615 | this.dataType = null; 616 | this.error = null; 617 | this.meta = null; 618 | this.stream = null; 619 | this.seq = null; 620 | if (args) { 621 | if (args.ver !== undefined && args.ver !== null) { 622 | this.ver = args.ver; 623 | } 624 | if (args.sender !== undefined && args.sender !== null) { 625 | this.sender = args.sender; 626 | } 627 | if (args.id !== undefined && args.id !== null) { 628 | this.id = args.id; 629 | } 630 | if (args.success !== undefined && args.success !== null) { 631 | this.success = args.success; 632 | } 633 | if (args.data !== undefined && args.data !== null) { 634 | this.data = args.data; 635 | } 636 | if (args.dataType !== undefined && args.dataType !== null) { 637 | this.dataType = args.dataType; 638 | } 639 | if (args.error !== undefined && args.error !== null) { 640 | this.error = args.error; 641 | } 642 | if (args.meta !== undefined && args.meta !== null) { 643 | this.meta = args.meta; 644 | } 645 | if (args.stream !== undefined && args.stream !== null) { 646 | this.stream = args.stream; 647 | } 648 | if (args.seq !== undefined && args.seq !== null) { 649 | this.seq = args.seq; 650 | } 651 | } 652 | }; 653 | PacketResponse.prototype = {}; 654 | PacketResponse.prototype.read = function(input) { 655 | input.readStructBegin(); 656 | while (true) { 657 | let ret = input.readFieldBegin(); 658 | let ftype = ret.ftype; 659 | let fid = ret.fid; 660 | if (ftype == Thrift.Type.STOP) { 661 | break; 662 | } 663 | switch (fid) { 664 | case 1: 665 | if (ftype == Thrift.Type.STRING) { 666 | this.ver = input.readString(); 667 | } else { 668 | input.skip(ftype); 669 | } 670 | break; 671 | case 2: 672 | if (ftype == Thrift.Type.STRING) { 673 | this.sender = input.readString(); 674 | } else { 675 | input.skip(ftype); 676 | } 677 | break; 678 | case 3: 679 | if (ftype == Thrift.Type.STRING) { 680 | this.id = input.readString(); 681 | } else { 682 | input.skip(ftype); 683 | } 684 | break; 685 | case 4: 686 | if (ftype == Thrift.Type.BOOL) { 687 | this.success = input.readBool(); 688 | } else { 689 | input.skip(ftype); 690 | } 691 | break; 692 | case 5: 693 | if (ftype == Thrift.Type.STRING) { 694 | this.data = input.readBinary(); 695 | } else { 696 | input.skip(ftype); 697 | } 698 | break; 699 | case 6: 700 | if (ftype == Thrift.Type.I32) { 701 | this.dataType = input.readI32(); 702 | } else { 703 | input.skip(ftype); 704 | } 705 | break; 706 | case 7: 707 | if (ftype == Thrift.Type.STRING) { 708 | this.error = input.readString(); 709 | } else { 710 | input.skip(ftype); 711 | } 712 | break; 713 | case 8: 714 | if (ftype == Thrift.Type.STRING) { 715 | this.meta = input.readString(); 716 | } else { 717 | input.skip(ftype); 718 | } 719 | break; 720 | case 9: 721 | if (ftype == Thrift.Type.BOOL) { 722 | this.stream = input.readBool(); 723 | } else { 724 | input.skip(ftype); 725 | } 726 | break; 727 | case 10: 728 | if (ftype == Thrift.Type.I32) { 729 | this.seq = input.readI32(); 730 | } else { 731 | input.skip(ftype); 732 | } 733 | break; 734 | default: 735 | input.skip(ftype); 736 | } 737 | input.readFieldEnd(); 738 | } 739 | input.readStructEnd(); 740 | return; 741 | }; 742 | 743 | PacketResponse.prototype.write = function(output) { 744 | output.writeStructBegin("PacketResponse"); 745 | if (this.ver !== null && this.ver !== undefined) { 746 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 747 | output.writeString(this.ver); 748 | output.writeFieldEnd(); 749 | } 750 | if (this.sender !== null && this.sender !== undefined) { 751 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 752 | output.writeString(this.sender); 753 | output.writeFieldEnd(); 754 | } 755 | if (this.id !== null && this.id !== undefined) { 756 | output.writeFieldBegin("id", Thrift.Type.STRING, 3); 757 | output.writeString(this.id); 758 | output.writeFieldEnd(); 759 | } 760 | if (this.success !== null && this.success !== undefined) { 761 | output.writeFieldBegin("success", Thrift.Type.BOOL, 4); 762 | output.writeBool(this.success); 763 | output.writeFieldEnd(); 764 | } 765 | if (this.data !== null && this.data !== undefined) { 766 | output.writeFieldBegin("data", Thrift.Type.STRING, 5); 767 | output.writeBinary(this.data); 768 | output.writeFieldEnd(); 769 | } 770 | if (this.dataType !== null && this.dataType !== undefined) { 771 | output.writeFieldBegin("dataType", Thrift.Type.I32, 6); 772 | output.writeI32(this.dataType); 773 | output.writeFieldEnd(); 774 | } 775 | if (this.error !== null && this.error !== undefined) { 776 | output.writeFieldBegin("error", Thrift.Type.STRING, 7); 777 | output.writeString(this.error); 778 | output.writeFieldEnd(); 779 | } 780 | if (this.meta !== null && this.meta !== undefined) { 781 | output.writeFieldBegin("meta", Thrift.Type.STRING, 8); 782 | output.writeString(this.meta); 783 | output.writeFieldEnd(); 784 | } 785 | if (this.stream !== null && this.stream !== undefined) { 786 | output.writeFieldBegin("stream", Thrift.Type.BOOL, 9); 787 | output.writeBool(this.stream); 788 | output.writeFieldEnd(); 789 | } 790 | if (this.seq !== null && this.seq !== undefined) { 791 | output.writeFieldBegin("seq", Thrift.Type.I32, 10); 792 | output.writeI32(this.seq); 793 | output.writeFieldEnd(); 794 | } 795 | output.writeFieldStop(); 796 | output.writeStructEnd(); 797 | return; 798 | }; 799 | 800 | let PacketDiscover = module.exports.PacketDiscover = function(args) { 801 | this.ver = null; 802 | this.sender = null; 803 | if (args) { 804 | if (args.ver !== undefined && args.ver !== null) { 805 | this.ver = args.ver; 806 | } 807 | if (args.sender !== undefined && args.sender !== null) { 808 | this.sender = args.sender; 809 | } 810 | } 811 | }; 812 | PacketDiscover.prototype = {}; 813 | PacketDiscover.prototype.read = function(input) { 814 | input.readStructBegin(); 815 | while (true) { 816 | let ret = input.readFieldBegin(); 817 | let ftype = ret.ftype; 818 | let fid = ret.fid; 819 | if (ftype == Thrift.Type.STOP) { 820 | break; 821 | } 822 | switch (fid) { 823 | case 1: 824 | if (ftype == Thrift.Type.STRING) { 825 | this.ver = input.readString(); 826 | } else { 827 | input.skip(ftype); 828 | } 829 | break; 830 | case 2: 831 | if (ftype == Thrift.Type.STRING) { 832 | this.sender = input.readString(); 833 | } else { 834 | input.skip(ftype); 835 | } 836 | break; 837 | default: 838 | input.skip(ftype); 839 | } 840 | input.readFieldEnd(); 841 | } 842 | input.readStructEnd(); 843 | return; 844 | }; 845 | 846 | PacketDiscover.prototype.write = function(output) { 847 | output.writeStructBegin("PacketDiscover"); 848 | if (this.ver !== null && this.ver !== undefined) { 849 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 850 | output.writeString(this.ver); 851 | output.writeFieldEnd(); 852 | } 853 | if (this.sender !== null && this.sender !== undefined) { 854 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 855 | output.writeString(this.sender); 856 | output.writeFieldEnd(); 857 | } 858 | output.writeFieldStop(); 859 | output.writeStructEnd(); 860 | return; 861 | }; 862 | 863 | let Client = module.exports.Client = function(args) { 864 | this.type = null; 865 | this.version = null; 866 | this.langVersion = null; 867 | if (args) { 868 | if (args.type !== undefined && args.type !== null) { 869 | this.type = args.type; 870 | } 871 | if (args.version !== undefined && args.version !== null) { 872 | this.version = args.version; 873 | } 874 | if (args.langVersion !== undefined && args.langVersion !== null) { 875 | this.langVersion = args.langVersion; 876 | } 877 | } 878 | }; 879 | Client.prototype = {}; 880 | Client.prototype.read = function(input) { 881 | input.readStructBegin(); 882 | while (true) { 883 | let ret = input.readFieldBegin(); 884 | let ftype = ret.ftype; 885 | let fid = ret.fid; 886 | if (ftype == Thrift.Type.STOP) { 887 | break; 888 | } 889 | switch (fid) { 890 | case 1: 891 | if (ftype == Thrift.Type.STRING) { 892 | this.type = input.readString(); 893 | } else { 894 | input.skip(ftype); 895 | } 896 | break; 897 | case 2: 898 | if (ftype == Thrift.Type.STRING) { 899 | this.version = input.readString(); 900 | } else { 901 | input.skip(ftype); 902 | } 903 | break; 904 | case 3: 905 | if (ftype == Thrift.Type.STRING) { 906 | this.langVersion = input.readString(); 907 | } else { 908 | input.skip(ftype); 909 | } 910 | break; 911 | default: 912 | input.skip(ftype); 913 | } 914 | input.readFieldEnd(); 915 | } 916 | input.readStructEnd(); 917 | return; 918 | }; 919 | 920 | Client.prototype.write = function(output) { 921 | output.writeStructBegin("Client"); 922 | if (this.type !== null && this.type !== undefined) { 923 | output.writeFieldBegin("type", Thrift.Type.STRING, 1); 924 | output.writeString(this.type); 925 | output.writeFieldEnd(); 926 | } 927 | if (this.version !== null && this.version !== undefined) { 928 | output.writeFieldBegin("version", Thrift.Type.STRING, 2); 929 | output.writeString(this.version); 930 | output.writeFieldEnd(); 931 | } 932 | if (this.langVersion !== null && this.langVersion !== undefined) { 933 | output.writeFieldBegin("langVersion", Thrift.Type.STRING, 3); 934 | output.writeString(this.langVersion); 935 | output.writeFieldEnd(); 936 | } 937 | output.writeFieldStop(); 938 | output.writeStructEnd(); 939 | return; 940 | }; 941 | 942 | let PacketInfo = module.exports.PacketInfo = function(args) { 943 | this.ver = null; 944 | this.sender = null; 945 | this.services = null; 946 | this.config = null; 947 | this.ipList = null; 948 | this.hostname = null; 949 | this.client = null; 950 | this.seq = null; 951 | this.instanceID = null; 952 | this.metadata = null; 953 | if (args) { 954 | if (args.ver !== undefined && args.ver !== null) { 955 | this.ver = args.ver; 956 | } 957 | if (args.sender !== undefined && args.sender !== null) { 958 | this.sender = args.sender; 959 | } 960 | if (args.services !== undefined && args.services !== null) { 961 | this.services = args.services; 962 | } 963 | if (args.config !== undefined && args.config !== null) { 964 | this.config = args.config; 965 | } 966 | if (args.ipList !== undefined && args.ipList !== null) { 967 | this.ipList = Thrift.copyList(args.ipList, [null]); 968 | } 969 | if (args.hostname !== undefined && args.hostname !== null) { 970 | this.hostname = args.hostname; 971 | } 972 | if (args.client !== undefined && args.client !== null) { 973 | this.client = new ttypes.Client(args.client); 974 | } 975 | if (args.seq !== undefined && args.seq !== null) { 976 | this.seq = args.seq; 977 | } 978 | if (args.instanceID !== undefined && args.instanceID !== null) { 979 | this.instanceID = args.instanceID; 980 | } 981 | if (args.metadata !== undefined && args.metadata !== null) { 982 | this.metadata = args.metadata; 983 | } 984 | } 985 | }; 986 | PacketInfo.prototype = {}; 987 | PacketInfo.prototype.read = function(input) { 988 | input.readStructBegin(); 989 | while (true) { 990 | let ret = input.readFieldBegin(); 991 | let ftype = ret.ftype; 992 | let fid = ret.fid; 993 | if (ftype == Thrift.Type.STOP) { 994 | break; 995 | } 996 | switch (fid) { 997 | case 1: 998 | if (ftype == Thrift.Type.STRING) { 999 | this.ver = input.readString(); 1000 | } else { 1001 | input.skip(ftype); 1002 | } 1003 | break; 1004 | case 2: 1005 | if (ftype == Thrift.Type.STRING) { 1006 | this.sender = input.readString(); 1007 | } else { 1008 | input.skip(ftype); 1009 | } 1010 | break; 1011 | case 3: 1012 | if (ftype == Thrift.Type.STRING) { 1013 | this.services = input.readString(); 1014 | } else { 1015 | input.skip(ftype); 1016 | } 1017 | break; 1018 | case 4: 1019 | if (ftype == Thrift.Type.STRING) { 1020 | this.config = input.readString(); 1021 | } else { 1022 | input.skip(ftype); 1023 | } 1024 | break; 1025 | case 5: 1026 | if (ftype == Thrift.Type.LIST) { 1027 | this.ipList = []; 1028 | let _rtmp36 = input.readListBegin(); 1029 | let _size5 = _rtmp36.size || 0; 1030 | for (let _i7 = 0; _i7 < _size5; ++_i7) { 1031 | let elem8 = null; 1032 | elem8 = input.readString(); 1033 | this.ipList.push(elem8); 1034 | } 1035 | input.readListEnd(); 1036 | } else { 1037 | input.skip(ftype); 1038 | } 1039 | break; 1040 | case 6: 1041 | if (ftype == Thrift.Type.STRING) { 1042 | this.hostname = input.readString(); 1043 | } else { 1044 | input.skip(ftype); 1045 | } 1046 | break; 1047 | case 7: 1048 | if (ftype == Thrift.Type.STRUCT) { 1049 | this.client = new ttypes.Client(); 1050 | this.client.read(input); 1051 | } else { 1052 | input.skip(ftype); 1053 | } 1054 | break; 1055 | case 8: 1056 | if (ftype == Thrift.Type.I32) { 1057 | this.seq = input.readI32(); 1058 | } else { 1059 | input.skip(ftype); 1060 | } 1061 | break; 1062 | case 9: 1063 | if (ftype == Thrift.Type.STRING) { 1064 | this.instanceID = input.readString(); 1065 | } else { 1066 | input.skip(ftype); 1067 | } 1068 | break; 1069 | case 10: 1070 | if (ftype == Thrift.Type.STRING) { 1071 | this.metadata = input.readString(); 1072 | } else { 1073 | input.skip(ftype); 1074 | } 1075 | break; 1076 | default: 1077 | input.skip(ftype); 1078 | } 1079 | input.readFieldEnd(); 1080 | } 1081 | input.readStructEnd(); 1082 | return; 1083 | }; 1084 | 1085 | PacketInfo.prototype.write = function(output) { 1086 | output.writeStructBegin("PacketInfo"); 1087 | if (this.ver !== null && this.ver !== undefined) { 1088 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 1089 | output.writeString(this.ver); 1090 | output.writeFieldEnd(); 1091 | } 1092 | if (this.sender !== null && this.sender !== undefined) { 1093 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 1094 | output.writeString(this.sender); 1095 | output.writeFieldEnd(); 1096 | } 1097 | if (this.services !== null && this.services !== undefined) { 1098 | output.writeFieldBegin("services", Thrift.Type.STRING, 3); 1099 | output.writeString(this.services); 1100 | output.writeFieldEnd(); 1101 | } 1102 | if (this.config !== null && this.config !== undefined) { 1103 | output.writeFieldBegin("config", Thrift.Type.STRING, 4); 1104 | output.writeString(this.config); 1105 | output.writeFieldEnd(); 1106 | } 1107 | if (this.ipList !== null && this.ipList !== undefined) { 1108 | output.writeFieldBegin("ipList", Thrift.Type.LIST, 5); 1109 | output.writeListBegin(Thrift.Type.STRING, this.ipList.length); 1110 | for (let iter9 in this.ipList) { 1111 | if (this.ipList.hasOwnProperty(iter9)) { 1112 | iter9 = this.ipList[iter9]; 1113 | output.writeString(iter9); 1114 | } 1115 | } 1116 | output.writeListEnd(); 1117 | output.writeFieldEnd(); 1118 | } 1119 | if (this.hostname !== null && this.hostname !== undefined) { 1120 | output.writeFieldBegin("hostname", Thrift.Type.STRING, 6); 1121 | output.writeString(this.hostname); 1122 | output.writeFieldEnd(); 1123 | } 1124 | if (this.client !== null && this.client !== undefined) { 1125 | output.writeFieldBegin("client", Thrift.Type.STRUCT, 7); 1126 | this.client.write(output); 1127 | output.writeFieldEnd(); 1128 | } 1129 | if (this.seq !== null && this.seq !== undefined) { 1130 | output.writeFieldBegin("seq", Thrift.Type.I32, 8); 1131 | output.writeI32(this.seq); 1132 | output.writeFieldEnd(); 1133 | } 1134 | if (this.instanceID !== null && this.instanceID !== undefined) { 1135 | output.writeFieldBegin("instanceID", Thrift.Type.STRING, 9); 1136 | output.writeString(this.instanceID); 1137 | output.writeFieldEnd(); 1138 | } 1139 | if (this.metadata !== null && this.metadata !== undefined) { 1140 | output.writeFieldBegin("metadata", Thrift.Type.STRING, 10); 1141 | output.writeString(this.metadata); 1142 | output.writeFieldEnd(); 1143 | } 1144 | output.writeFieldStop(); 1145 | output.writeStructEnd(); 1146 | return; 1147 | }; 1148 | 1149 | let PacketDisconnect = module.exports.PacketDisconnect = function(args) { 1150 | this.ver = null; 1151 | this.sender = null; 1152 | if (args) { 1153 | if (args.ver !== undefined && args.ver !== null) { 1154 | this.ver = args.ver; 1155 | } 1156 | if (args.sender !== undefined && args.sender !== null) { 1157 | this.sender = args.sender; 1158 | } 1159 | } 1160 | }; 1161 | PacketDisconnect.prototype = {}; 1162 | PacketDisconnect.prototype.read = function(input) { 1163 | input.readStructBegin(); 1164 | while (true) { 1165 | let ret = input.readFieldBegin(); 1166 | let ftype = ret.ftype; 1167 | let fid = ret.fid; 1168 | if (ftype == Thrift.Type.STOP) { 1169 | break; 1170 | } 1171 | switch (fid) { 1172 | case 1: 1173 | if (ftype == Thrift.Type.STRING) { 1174 | this.ver = input.readString(); 1175 | } else { 1176 | input.skip(ftype); 1177 | } 1178 | break; 1179 | case 2: 1180 | if (ftype == Thrift.Type.STRING) { 1181 | this.sender = input.readString(); 1182 | } else { 1183 | input.skip(ftype); 1184 | } 1185 | break; 1186 | default: 1187 | input.skip(ftype); 1188 | } 1189 | input.readFieldEnd(); 1190 | } 1191 | input.readStructEnd(); 1192 | return; 1193 | }; 1194 | 1195 | PacketDisconnect.prototype.write = function(output) { 1196 | output.writeStructBegin("PacketDisconnect"); 1197 | if (this.ver !== null && this.ver !== undefined) { 1198 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 1199 | output.writeString(this.ver); 1200 | output.writeFieldEnd(); 1201 | } 1202 | if (this.sender !== null && this.sender !== undefined) { 1203 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 1204 | output.writeString(this.sender); 1205 | output.writeFieldEnd(); 1206 | } 1207 | output.writeFieldStop(); 1208 | output.writeStructEnd(); 1209 | return; 1210 | }; 1211 | 1212 | let PacketHeartbeat = module.exports.PacketHeartbeat = function(args) { 1213 | this.ver = null; 1214 | this.sender = null; 1215 | this.cpu = null; 1216 | if (args) { 1217 | if (args.ver !== undefined && args.ver !== null) { 1218 | this.ver = args.ver; 1219 | } 1220 | if (args.sender !== undefined && args.sender !== null) { 1221 | this.sender = args.sender; 1222 | } 1223 | if (args.cpu !== undefined && args.cpu !== null) { 1224 | this.cpu = args.cpu; 1225 | } 1226 | } 1227 | }; 1228 | PacketHeartbeat.prototype = {}; 1229 | PacketHeartbeat.prototype.read = function(input) { 1230 | input.readStructBegin(); 1231 | while (true) { 1232 | let ret = input.readFieldBegin(); 1233 | let ftype = ret.ftype; 1234 | let fid = ret.fid; 1235 | if (ftype == Thrift.Type.STOP) { 1236 | break; 1237 | } 1238 | switch (fid) { 1239 | case 1: 1240 | if (ftype == Thrift.Type.STRING) { 1241 | this.ver = input.readString(); 1242 | } else { 1243 | input.skip(ftype); 1244 | } 1245 | break; 1246 | case 2: 1247 | if (ftype == Thrift.Type.STRING) { 1248 | this.sender = input.readString(); 1249 | } else { 1250 | input.skip(ftype); 1251 | } 1252 | break; 1253 | case 3: 1254 | if (ftype == Thrift.Type.DOUBLE) { 1255 | this.cpu = input.readDouble(); 1256 | } else { 1257 | input.skip(ftype); 1258 | } 1259 | break; 1260 | default: 1261 | input.skip(ftype); 1262 | } 1263 | input.readFieldEnd(); 1264 | } 1265 | input.readStructEnd(); 1266 | return; 1267 | }; 1268 | 1269 | PacketHeartbeat.prototype.write = function(output) { 1270 | output.writeStructBegin("PacketHeartbeat"); 1271 | if (this.ver !== null && this.ver !== undefined) { 1272 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 1273 | output.writeString(this.ver); 1274 | output.writeFieldEnd(); 1275 | } 1276 | if (this.sender !== null && this.sender !== undefined) { 1277 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 1278 | output.writeString(this.sender); 1279 | output.writeFieldEnd(); 1280 | } 1281 | if (this.cpu !== null && this.cpu !== undefined) { 1282 | output.writeFieldBegin("cpu", Thrift.Type.DOUBLE, 3); 1283 | output.writeDouble(this.cpu); 1284 | output.writeFieldEnd(); 1285 | } 1286 | output.writeFieldStop(); 1287 | output.writeStructEnd(); 1288 | return; 1289 | }; 1290 | 1291 | let PacketPing = module.exports.PacketPing = function(args) { 1292 | this.ver = null; 1293 | this.sender = null; 1294 | this.time = null; 1295 | this.id = null; 1296 | if (args) { 1297 | if (args.ver !== undefined && args.ver !== null) { 1298 | this.ver = args.ver; 1299 | } 1300 | if (args.sender !== undefined && args.sender !== null) { 1301 | this.sender = args.sender; 1302 | } 1303 | if (args.time !== undefined && args.time !== null) { 1304 | this.time = args.time; 1305 | } 1306 | if (args.id !== undefined && args.id !== null) { 1307 | this.id = args.id; 1308 | } 1309 | } 1310 | }; 1311 | PacketPing.prototype = {}; 1312 | PacketPing.prototype.read = function(input) { 1313 | input.readStructBegin(); 1314 | while (true) { 1315 | let ret = input.readFieldBegin(); 1316 | let ftype = ret.ftype; 1317 | let fid = ret.fid; 1318 | if (ftype == Thrift.Type.STOP) { 1319 | break; 1320 | } 1321 | switch (fid) { 1322 | case 1: 1323 | if (ftype == Thrift.Type.STRING) { 1324 | this.ver = input.readString(); 1325 | } else { 1326 | input.skip(ftype); 1327 | } 1328 | break; 1329 | case 2: 1330 | if (ftype == Thrift.Type.STRING) { 1331 | this.sender = input.readString(); 1332 | } else { 1333 | input.skip(ftype); 1334 | } 1335 | break; 1336 | case 3: 1337 | if (ftype == Thrift.Type.I64) { 1338 | this.time = input.readI64(); 1339 | } else { 1340 | input.skip(ftype); 1341 | } 1342 | break; 1343 | case 4: 1344 | if (ftype == Thrift.Type.STRING) { 1345 | this.id = input.readString(); 1346 | } else { 1347 | input.skip(ftype); 1348 | } 1349 | break; 1350 | default: 1351 | input.skip(ftype); 1352 | } 1353 | input.readFieldEnd(); 1354 | } 1355 | input.readStructEnd(); 1356 | return; 1357 | }; 1358 | 1359 | PacketPing.prototype.write = function(output) { 1360 | output.writeStructBegin("PacketPing"); 1361 | if (this.ver !== null && this.ver !== undefined) { 1362 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 1363 | output.writeString(this.ver); 1364 | output.writeFieldEnd(); 1365 | } 1366 | if (this.sender !== null && this.sender !== undefined) { 1367 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 1368 | output.writeString(this.sender); 1369 | output.writeFieldEnd(); 1370 | } 1371 | if (this.time !== null && this.time !== undefined) { 1372 | output.writeFieldBegin("time", Thrift.Type.I64, 3); 1373 | output.writeI64(this.time); 1374 | output.writeFieldEnd(); 1375 | } 1376 | if (this.id !== null && this.id !== undefined) { 1377 | output.writeFieldBegin("id", Thrift.Type.STRING, 4); 1378 | output.writeString(this.id); 1379 | output.writeFieldEnd(); 1380 | } 1381 | output.writeFieldStop(); 1382 | output.writeStructEnd(); 1383 | return; 1384 | }; 1385 | 1386 | let PacketPong = module.exports.PacketPong = function(args) { 1387 | this.ver = null; 1388 | this.sender = null; 1389 | this.time = null; 1390 | this.arrived = null; 1391 | this.id = null; 1392 | if (args) { 1393 | if (args.ver !== undefined && args.ver !== null) { 1394 | this.ver = args.ver; 1395 | } 1396 | if (args.sender !== undefined && args.sender !== null) { 1397 | this.sender = args.sender; 1398 | } 1399 | if (args.time !== undefined && args.time !== null) { 1400 | this.time = args.time; 1401 | } 1402 | if (args.arrived !== undefined && args.arrived !== null) { 1403 | this.arrived = args.arrived; 1404 | } 1405 | if (args.id !== undefined && args.id !== null) { 1406 | this.id = args.id; 1407 | } 1408 | } 1409 | }; 1410 | PacketPong.prototype = {}; 1411 | PacketPong.prototype.read = function(input) { 1412 | input.readStructBegin(); 1413 | while (true) { 1414 | let ret = input.readFieldBegin(); 1415 | let ftype = ret.ftype; 1416 | let fid = ret.fid; 1417 | if (ftype == Thrift.Type.STOP) { 1418 | break; 1419 | } 1420 | switch (fid) { 1421 | case 1: 1422 | if (ftype == Thrift.Type.STRING) { 1423 | this.ver = input.readString(); 1424 | } else { 1425 | input.skip(ftype); 1426 | } 1427 | break; 1428 | case 2: 1429 | if (ftype == Thrift.Type.STRING) { 1430 | this.sender = input.readString(); 1431 | } else { 1432 | input.skip(ftype); 1433 | } 1434 | break; 1435 | case 3: 1436 | if (ftype == Thrift.Type.I64) { 1437 | this.time = input.readI64(); 1438 | } else { 1439 | input.skip(ftype); 1440 | } 1441 | break; 1442 | case 4: 1443 | if (ftype == Thrift.Type.I64) { 1444 | this.arrived = input.readI64(); 1445 | } else { 1446 | input.skip(ftype); 1447 | } 1448 | break; 1449 | case 5: 1450 | if (ftype == Thrift.Type.STRING) { 1451 | this.id = input.readString(); 1452 | } else { 1453 | input.skip(ftype); 1454 | } 1455 | break; 1456 | default: 1457 | input.skip(ftype); 1458 | } 1459 | input.readFieldEnd(); 1460 | } 1461 | input.readStructEnd(); 1462 | return; 1463 | }; 1464 | 1465 | PacketPong.prototype.write = function(output) { 1466 | output.writeStructBegin("PacketPong"); 1467 | if (this.ver !== null && this.ver !== undefined) { 1468 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 1469 | output.writeString(this.ver); 1470 | output.writeFieldEnd(); 1471 | } 1472 | if (this.sender !== null && this.sender !== undefined) { 1473 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 1474 | output.writeString(this.sender); 1475 | output.writeFieldEnd(); 1476 | } 1477 | if (this.time !== null && this.time !== undefined) { 1478 | output.writeFieldBegin("time", Thrift.Type.I64, 3); 1479 | output.writeI64(this.time); 1480 | output.writeFieldEnd(); 1481 | } 1482 | if (this.arrived !== null && this.arrived !== undefined) { 1483 | output.writeFieldBegin("arrived", Thrift.Type.I64, 4); 1484 | output.writeI64(this.arrived); 1485 | output.writeFieldEnd(); 1486 | } 1487 | if (this.id !== null && this.id !== undefined) { 1488 | output.writeFieldBegin("id", Thrift.Type.STRING, 5); 1489 | output.writeString(this.id); 1490 | output.writeFieldEnd(); 1491 | } 1492 | output.writeFieldStop(); 1493 | output.writeStructEnd(); 1494 | return; 1495 | }; 1496 | 1497 | let PacketGossipHello = module.exports.PacketGossipHello = function(args) { 1498 | this.ver = null; 1499 | this.sender = null; 1500 | this.host = null; 1501 | this.port = null; 1502 | if (args) { 1503 | if (args.ver !== undefined && args.ver !== null) { 1504 | this.ver = args.ver; 1505 | } 1506 | if (args.sender !== undefined && args.sender !== null) { 1507 | this.sender = args.sender; 1508 | } 1509 | if (args.host !== undefined && args.host !== null) { 1510 | this.host = args.host; 1511 | } 1512 | if (args.port !== undefined && args.port !== null) { 1513 | this.port = args.port; 1514 | } 1515 | } 1516 | }; 1517 | PacketGossipHello.prototype = {}; 1518 | PacketGossipHello.prototype.read = function(input) { 1519 | input.readStructBegin(); 1520 | while (true) { 1521 | let ret = input.readFieldBegin(); 1522 | let ftype = ret.ftype; 1523 | let fid = ret.fid; 1524 | if (ftype == Thrift.Type.STOP) { 1525 | break; 1526 | } 1527 | switch (fid) { 1528 | case 1: 1529 | if (ftype == Thrift.Type.STRING) { 1530 | this.ver = input.readString(); 1531 | } else { 1532 | input.skip(ftype); 1533 | } 1534 | break; 1535 | case 2: 1536 | if (ftype == Thrift.Type.STRING) { 1537 | this.sender = input.readString(); 1538 | } else { 1539 | input.skip(ftype); 1540 | } 1541 | break; 1542 | case 3: 1543 | if (ftype == Thrift.Type.STRING) { 1544 | this.host = input.readString(); 1545 | } else { 1546 | input.skip(ftype); 1547 | } 1548 | break; 1549 | case 4: 1550 | if (ftype == Thrift.Type.I32) { 1551 | this.port = input.readI32(); 1552 | } else { 1553 | input.skip(ftype); 1554 | } 1555 | break; 1556 | default: 1557 | input.skip(ftype); 1558 | } 1559 | input.readFieldEnd(); 1560 | } 1561 | input.readStructEnd(); 1562 | return; 1563 | }; 1564 | 1565 | PacketGossipHello.prototype.write = function(output) { 1566 | output.writeStructBegin("PacketGossipHello"); 1567 | if (this.ver !== null && this.ver !== undefined) { 1568 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 1569 | output.writeString(this.ver); 1570 | output.writeFieldEnd(); 1571 | } 1572 | if (this.sender !== null && this.sender !== undefined) { 1573 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 1574 | output.writeString(this.sender); 1575 | output.writeFieldEnd(); 1576 | } 1577 | if (this.host !== null && this.host !== undefined) { 1578 | output.writeFieldBegin("host", Thrift.Type.STRING, 3); 1579 | output.writeString(this.host); 1580 | output.writeFieldEnd(); 1581 | } 1582 | if (this.port !== null && this.port !== undefined) { 1583 | output.writeFieldBegin("port", Thrift.Type.I32, 4); 1584 | output.writeI32(this.port); 1585 | output.writeFieldEnd(); 1586 | } 1587 | output.writeFieldStop(); 1588 | output.writeStructEnd(); 1589 | return; 1590 | }; 1591 | 1592 | let PacketGossipRequest = module.exports.PacketGossipRequest = function(args) { 1593 | this.ver = null; 1594 | this.sender = null; 1595 | this.online = null; 1596 | this.offline = null; 1597 | if (args) { 1598 | if (args.ver !== undefined && args.ver !== null) { 1599 | this.ver = args.ver; 1600 | } 1601 | if (args.sender !== undefined && args.sender !== null) { 1602 | this.sender = args.sender; 1603 | } 1604 | if (args.online !== undefined && args.online !== null) { 1605 | this.online = args.online; 1606 | } 1607 | if (args.offline !== undefined && args.offline !== null) { 1608 | this.offline = args.offline; 1609 | } 1610 | } 1611 | }; 1612 | PacketGossipRequest.prototype = {}; 1613 | PacketGossipRequest.prototype.read = function(input) { 1614 | input.readStructBegin(); 1615 | while (true) { 1616 | let ret = input.readFieldBegin(); 1617 | let ftype = ret.ftype; 1618 | let fid = ret.fid; 1619 | if (ftype == Thrift.Type.STOP) { 1620 | break; 1621 | } 1622 | switch (fid) { 1623 | case 1: 1624 | if (ftype == Thrift.Type.STRING) { 1625 | this.ver = input.readString(); 1626 | } else { 1627 | input.skip(ftype); 1628 | } 1629 | break; 1630 | case 2: 1631 | if (ftype == Thrift.Type.STRING) { 1632 | this.sender = input.readString(); 1633 | } else { 1634 | input.skip(ftype); 1635 | } 1636 | break; 1637 | case 3: 1638 | if (ftype == Thrift.Type.STRING) { 1639 | this.online = input.readString(); 1640 | } else { 1641 | input.skip(ftype); 1642 | } 1643 | break; 1644 | case 4: 1645 | if (ftype == Thrift.Type.STRING) { 1646 | this.offline = input.readString(); 1647 | } else { 1648 | input.skip(ftype); 1649 | } 1650 | break; 1651 | default: 1652 | input.skip(ftype); 1653 | } 1654 | input.readFieldEnd(); 1655 | } 1656 | input.readStructEnd(); 1657 | return; 1658 | }; 1659 | 1660 | PacketGossipRequest.prototype.write = function(output) { 1661 | output.writeStructBegin("PacketGossipRequest"); 1662 | if (this.ver !== null && this.ver !== undefined) { 1663 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 1664 | output.writeString(this.ver); 1665 | output.writeFieldEnd(); 1666 | } 1667 | if (this.sender !== null && this.sender !== undefined) { 1668 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 1669 | output.writeString(this.sender); 1670 | output.writeFieldEnd(); 1671 | } 1672 | if (this.online !== null && this.online !== undefined) { 1673 | output.writeFieldBegin("online", Thrift.Type.STRING, 3); 1674 | output.writeString(this.online); 1675 | output.writeFieldEnd(); 1676 | } 1677 | if (this.offline !== null && this.offline !== undefined) { 1678 | output.writeFieldBegin("offline", Thrift.Type.STRING, 4); 1679 | output.writeString(this.offline); 1680 | output.writeFieldEnd(); 1681 | } 1682 | output.writeFieldStop(); 1683 | output.writeStructEnd(); 1684 | return; 1685 | }; 1686 | 1687 | let PacketGossipResponse = module.exports.PacketGossipResponse = function(args) { 1688 | this.ver = null; 1689 | this.sender = null; 1690 | this.online = null; 1691 | this.offline = null; 1692 | if (args) { 1693 | if (args.ver !== undefined && args.ver !== null) { 1694 | this.ver = args.ver; 1695 | } 1696 | if (args.sender !== undefined && args.sender !== null) { 1697 | this.sender = args.sender; 1698 | } 1699 | if (args.online !== undefined && args.online !== null) { 1700 | this.online = args.online; 1701 | } 1702 | if (args.offline !== undefined && args.offline !== null) { 1703 | this.offline = args.offline; 1704 | } 1705 | } 1706 | }; 1707 | PacketGossipResponse.prototype = {}; 1708 | PacketGossipResponse.prototype.read = function(input) { 1709 | input.readStructBegin(); 1710 | while (true) { 1711 | let ret = input.readFieldBegin(); 1712 | let ftype = ret.ftype; 1713 | let fid = ret.fid; 1714 | if (ftype == Thrift.Type.STOP) { 1715 | break; 1716 | } 1717 | switch (fid) { 1718 | case 1: 1719 | if (ftype == Thrift.Type.STRING) { 1720 | this.ver = input.readString(); 1721 | } else { 1722 | input.skip(ftype); 1723 | } 1724 | break; 1725 | case 2: 1726 | if (ftype == Thrift.Type.STRING) { 1727 | this.sender = input.readString(); 1728 | } else { 1729 | input.skip(ftype); 1730 | } 1731 | break; 1732 | case 3: 1733 | if (ftype == Thrift.Type.STRING) { 1734 | this.online = input.readString(); 1735 | } else { 1736 | input.skip(ftype); 1737 | } 1738 | break; 1739 | case 4: 1740 | if (ftype == Thrift.Type.STRING) { 1741 | this.offline = input.readString(); 1742 | } else { 1743 | input.skip(ftype); 1744 | } 1745 | break; 1746 | default: 1747 | input.skip(ftype); 1748 | } 1749 | input.readFieldEnd(); 1750 | } 1751 | input.readStructEnd(); 1752 | return; 1753 | }; 1754 | 1755 | PacketGossipResponse.prototype.write = function(output) { 1756 | output.writeStructBegin("PacketGossipResponse"); 1757 | if (this.ver !== null && this.ver !== undefined) { 1758 | output.writeFieldBegin("ver", Thrift.Type.STRING, 1); 1759 | output.writeString(this.ver); 1760 | output.writeFieldEnd(); 1761 | } 1762 | if (this.sender !== null && this.sender !== undefined) { 1763 | output.writeFieldBegin("sender", Thrift.Type.STRING, 2); 1764 | output.writeString(this.sender); 1765 | output.writeFieldEnd(); 1766 | } 1767 | if (this.online !== null && this.online !== undefined) { 1768 | output.writeFieldBegin("online", Thrift.Type.STRING, 3); 1769 | output.writeString(this.online); 1770 | output.writeFieldEnd(); 1771 | } 1772 | if (this.offline !== null && this.offline !== undefined) { 1773 | output.writeFieldBegin("offline", Thrift.Type.STRING, 4); 1774 | output.writeString(this.offline); 1775 | output.writeFieldEnd(); 1776 | } 1777 | output.writeFieldStop(); 1778 | output.writeStructEnd(); 1779 | return; 1780 | }; 1781 | 1782 | --------------------------------------------------------------------------------