Kind: Interface
Source: packages/microservices/helpers/json-socket.ts
Part of: Microservices
JsonSocketOptions configures buffering behavior for the JSON socket helper used by the microservices transport layer. Its maxBufferSize property defines the maximum amount of incoming data that may be buffered while assembling and parsing JSON messages.
Properties
| Property | Type |
|---|---|
maxBufferSize | number |
Diagram
mermaidgraph LR Client[Socket Client] --> Socket[JSON Socket] Socket --> Buffer[Incoming Data Buffer] Buffer --> Limit[maxBufferSize] Limit --> Parser[JSON Message Parser] Parser --> Handler[Microservice Handler]
Usage
tsimport { JsonSocketOptions } from './helpers/json-socket';
const socketOptions: JsonSocketOptions = {
// Limit buffered incoming socket data to 1 MB.
maxBufferSize: 1024 * 1024,
};
// Pass the options when creating or configuring the JSON socket.
const jsonSocket = new JsonSocket(socket, socketOptions);
AI Coding Instructions
- Set
maxBufferSizeto a value appropriate for expected message sizes and available memory. - Treat this limit as a safety boundary against malformed, incomplete, or excessively large socket payloads.
- Keep the value in bytes and document any non-default limits used by a transport configuration.
- Ensure socket integrations handle buffer-limit failures by closing, resetting, or reporting invalid connections as appropriate.
Was this page helpful?