Package Exports
- tcp-log-server
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tcp-log-server) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Serve an append-only log over TCP.
npm install --global tcp-log-server
tcp-log-serverLogs
The server uses pino logging. To improve console log output:
npm install --global pino
tcp-log-server | tee server.log | pinoEnvironment
Configure tcp-log-server with environment variables:
PORTfor TCPBLOBSdirectory for entry JSON files, named by hashLEVELDBdirectory for LevelDB data files
Node.js
The package exports a factory function. Given a pino log, a
LevelUP instance, an abstract-blob-store, and an EventEmitter,
it returns a TCP connection handler function suitable for
net.createServer(handler).
Protocol
The server accepts TCP connections. It enables keep-alive on each socket. All messages are newline-delimited JSON objects. tcp-log-client provides a high-level interface.
Clients can send:
Read
{"type":"read","from":0}On receipt, the server will begin sending log entries with indices
greater than or equal to from. Each entry will be sent like:
{"index":"1","entry":{"some":"entry"}}The server will send:
{"current":true}once it has sent all entries in the log as of the time the read message was received.
Write
{"type":"write","id":"some-id","entry":{"arbitrary":"data"}}require('uuid').v4(), with the uuid package, is an easy way to
generate id strings.
Once successfully appended to the log, the server will confirm the index of the newly appended entry.
{"id":"some-id","event":"wrote","index":44}The server will not echo the new entry back to the client that writes it.
If there is an error, the server will instead respond:
{"id":"some-id-string","error":"error-string"}