Skip to content

Commit 553fcfa

Browse files
committed
docs: ✏️ Updated the coordination server docs page
1 parent 58f366f commit 553fcfa

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

docs/docs/coordinator.md

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,53 @@
1-
# Coordination server
1+
# Coordination Server
22

3-
## Create the server
3+
## Creating the Server
44

5-
More about the server configuration options is [here](./index.md#coordination-server).
5+
> You can find the complete code for a server implementation example in the SDK repository under the `./examples/server` directory.
6+
7+
## Configuration
8+
9+
Below is an example of the configuration and implementation for the protocol coordination server.
10+
11+
To instantiate the server, you need to generate a peer key. The process of key generation is explained in detail [here](/#peer-key-generation).
612

713
```typescript
8-
import { ServerOptions, createServer, storage } from '@windingtree/sdk';
14+
import { ServerOptions } from '@windingtree/sdk-server';
15+
import { memoryStorage } from '@windingtree/sdk-storage';
16+
import { serverPeerKey } from './path/to/config.js';
917

1018
const options: ServerOptions = {
11-
messagesStorageInit: storage['YOUR_STORAGE_OPTION']
12-
.createInitializer
13-
/** Your storage configuration */
14-
(),
15-
/** Other server configuration options */
19+
port: 33333,
20+
peerKey: serverPeerKey,
21+
/**
22+
* This example uses MemoryStorage,
23+
* but in production, it is recommended to use Redis.
24+
**/
25+
messagesStorageInit: memoryStorage.createInitializer(),
1626
};
27+
```
28+
29+
For caching requests (clients' requests and suppliers' offers), the server uses storage. In this configuration example, we use the `memoryStorage` implementation offered by the SDK library. However, in your system, you are free to implement your own storage layer. For details, please see the [storage documentation](./storage.md).
1730

31+
To create the server, you can use the `createServer` function from the `@windingtree/sdk-server` library, passing in the `options` object defined earlier.
32+
33+
```typescript
34+
import { createServer } from '@windingtree/sdk-server';
35+
36+
// Using the `options` from the example above
1837
const server = createServer(options);
1938

2039
server.addEventListener('start', () => {
21-
logger.trace('🚀 Server started at', new Date().toISOString());
40+
console.log('🚀 Server started');
2241
});
2342

2443
server.addEventListener('stop', () => {
25-
logger.trace('👋 Server stopped at:', new Date().toISOString());
44+
console.log('👋 Server stopped');
2645
});
2746

2847
await server.start(); // Start the server
48+
49+
// ...
2950
await server.stop(); // Stop the server
3051
```
52+
53+
Once the server is started, it begins accepting connections from clients and supplier nodes and efficiently coordinates messages between them to facilitate seamless interactions within the protocol ecosystem.

0 commit comments

Comments
 (0)