Update ReadMe for HTTP Callbacks

This commit is contained in:
Mansehej Singh 2020-07-12 21:11:42 +05:30
parent adfb8724be
commit 968e71e038

View File

@ -40,6 +40,22 @@ See [LevelDB Persistence](https://github.com/yjs/y-leveldb) for more info.
PORT=1234 YPERSISTENCE=./dbDir node ./node_modules/y-websocket/bin/server.js PORT=1234 YPERSISTENCE=./dbDir node ./node_modules/y-websocket/bin/server.js
``` ```
**Websocket Server with HTTP callback**
Send a debounced callback to an HTTP server (POST) on document update.
Can take the following ENV variables:
- CALLBACK_URL : Callback server URL.
- CALLBACK_DEBOUNCE_WAIT : Debounce time between callbacks. Defaults to 2 seconds.
- CALLBACK_DEBOUNCE_MAXWAIT : Maximum time to wait before callback. Defaults to 10 seconds.
- CALLBACK_TIMEOUT : Timeout for the HTTP call. Defaults to 5 seconds.
- CALLBACK_OBJECTS : JSON of shared objects to get data. ('{"SHARED_OBJECT_NAME":"SHARED_OBJECT_TYPE}')
```sh
CALLBACK_URL=http://localhost:3000/ CALLBACK_OBJECTS='{"prosemirror":"XmlFragment"}' node ./node_modules/y-websocket/bin/server.js
```
This would send a callback to localhost:3000 every 2 seconds (default DEBOUNCE_WAIT) with the data of an XmlFragment named Prosemirror in the body.
### Scaling ### Scaling
These are mere suggestions how you could scale your server environment. These are mere suggestions how you could scale your server environment.