Skip to content

Commit

Permalink
update image links
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Sep 11, 2017
1 parent 77e0906 commit 1bcece0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/PROTOCOL.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@ After the client is connected to the message broker (NATS, Redis, MQTT), it subs
## Discovering
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 also own INFO packet to all other nodes.
![](http://moleculer.services/images/protocol-0.11/moleculer_protocol_discover.png)
![](http://moleculer.services/images/protocol-v2/moleculer_protocol_discover.png)

## Heartbeat
The client has to broadcast `HEARTBEAT` packets periodically. The period value comes from broker options (`heartbeatInterval`). Default value is 5 secs.
If the client doesn't receive `HEARTBEAT` for `heartbeatTimeout` seconds from a node, marks it to broken and doesn't route requests to this node.
![](http://moleculer.services/images/protocol-0.11/moleculer_protocol_heartbeat.png)
![](http://moleculer.services/images/protocol-v2/moleculer_protocol_heartbeat.png)

## Request-reply
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.
![](http://moleculer.services/images/protocol-0.11/moleculer_protocol_request.png)
![](http://moleculer.services/images/protocol-v2/moleculer_protocol_request.png)

## Event
When you call the `broker.emit` method, the broker sends an `EVENT` packet to the subscribed nodes. The broker groups & balances the subscribers, so only one instance per service receives the event.
![](http://moleculer.services/images/protocol-0.11/moleculer_protocol_event.png)
![](http://moleculer.services/images/protocol-v2/moleculer_protocol_event.png)

## Ping-pong
When you call the `broker.transit.sendPing` 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.
![](http://moleculer.services/images/protocol-0.11/moleculer_protocol_pong.png)
![](http://moleculer.services/images/protocol-v2/moleculer_protocol_pong.png)

## Disconnect
When a node is stopping, it broadcasts a `DISCONNECT` packet to all nodes.
![](http://moleculer.services/images/protocol-0.11/moleculer_protocol_disconnect.png)
![](http://moleculer.services/images/protocol-v2/moleculer_protocol_disconnect.png)

## Packets

Expand Down

0 comments on commit 1bcece0

Please sign in to comment.