8000 update README · github1/meshage@4ffa4ac · GitHub
[go: up one dir, main page]

Skip to content

Commit 4ffa4ac

Browse files
github1github1
authored andcommitted
update README
1 parent da11e53 commit 4ffa4ac

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

README.md

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ A simple service mesh. Messages sent within the service mesh can be consistently
1212
npm install meshage --save
1313
```
1414

15-
## Usage
15+
## Example
1616

17-
Initialize a node:
17+
Initialize a cluster/node:
1818

1919
```javascript
2020
const meshage = require('meshage');
@@ -33,14 +33,25 @@ meshage
3333
.start();
3434
```
3535

36-
Start one or more instances:
36+
Given the above example, create a cluster of nodes:
3737

38-
```shell
39-
CLUSTER_PORT=9742 SERVICE_PORT=8080 node index.js
38+
_Start a seed node_
39+
40+
```bash
41+
CLUSTER_PORT=9742 HTTP_PORT=8080 node index.js
42+
```
43+
44+
_Start other nodes referencing the seed address to join the cluster_
45+
```bash
4046
CLUSTER_PORT=9743 SEEDS=127.0.0.1:9742 HTTP_PORT=8081 node index.js
4147
```
4248

43-
Each node exposes an HTTP endpoint which accepts messages for registered streams. When a request is received by any instance registered to the cluster, a consistent hashing algorithm is used to determine which node should handle the request. If the node which receives the initial HTTP request is the designated handler it will respond directly, otherwise the receiving node will route the request to the designated node within the cluster.
49+
Each node exposes an HTTP endpoint which accepts messages for registered
50+
streams. When a request is received by any instance registered to the cluster,
51+
a consistent hashing algorithm is used to determine which node should handle
52+
the request. If the node which receives the initial HTTP request is the
53+
designated handler it will respond directly, otherwise the receiving node will
54+
route the request to the designated node within the cluster.
4455

4556
*Request:*
4657

@@ -63,20 +74,21 @@ curl -sX POST http://localhost:8080/api/echo/$RANDOM \
6374
## Supported protocols
6475

6576
Nodes in a cluster will automatically negotiate a protocol to use to
66-
send/receive messages. The following protocols are registered for each node.
77+
send/receive messages. The following protocols are registered for each node
78+
by default.
6779

6880
- [http](https://tools.ietf.org/html/rfc2616)
6981
- [rsocket](https://github.com/rsocket/rsocket-js)
7082
- [dnode](https://github.com/substack/dnode#readme)
7183

72-
By default, all of the above are enabled. You may configure a router with
73-
specific protocols as follows:
84+
You may configure a router with specific protocols as follows:
85+
86+
_The below example uses only the `RSocket` protocol._
7487

7588
```javascript
7689
const router = return new meshage.DefaultMessageRouter(
7790
cluster,
78-
new CompositeServiceInvoker(
79-
new RSocketServiceInvoker()),
91+
new RSocketServiceInvoker(),
8092
new RSocketMessageListener(`${addressStr}/find`)
8193
);
8294
```
@@ -163,9 +175,9 @@ Configure the cluster to join.
163175
const node = meshage.init(cluster, 8080);
164176
```
165177

166-
#### *Cluster Implementations:*
178+
#### Cluster Implementations:
167179

168-
#### GrapevineCluster
180+
##### GrapevineCluster
169181

170182
Leverages an implementation of the Gossip protocol to discover nodes and services.
171183

@@ -180,7 +192,7 @@ new meshage.GrapevineCluster(9473);
180192
new meshage.GrapevineCluster(9474, [9473]);
181193
```
182194

183-
#### ConsulCluster
195+
##### ConsulCluster
184196

185197
Connects to a consul agent/cluster for service registration.
186198

@@ -192,7 +204,7 @@ Connects to a consul agent/cluster for service registration.
192204
new meshage.ConsulCluster('127.0.0.1:8500');
193205
```
194206

195-
#### Custom Implementations
207+
##### Custom cluster implementations
196208

197209
Custom cluster types may be provided by implementing the `core/cluster/Cluster` interface.
198210

@@ -231,7 +243,9 @@ The `router` instance passed to the `start` callback exposes two methods:
231243

232244
### Send
233245

234-
Sends a message to be handled consistently by a registered handler for the specified stream. Depending on how the message is routed, it could be handled by the node itself.
246+
Sends a message to be handled consistently by a registered handler for the
247+
specified stream. Depending on how the message is routed, it could be handled
248+
by the node itself.
235249

236250
**send(message : Message) : Promise<{}>**
237251
- `message` - the message to send

0 commit comments

Comments
 (0)
0