-
Type: New Feature
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Connection Layer
Example
Provide a socket creator method to the MongoClient
Unable to find source-code formatter for language: typescript. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
const client = new MongoClient('xx', { createSocket(options) { return new MinimalSocketInterfaceImplemention(); } })
Details
Add support for providing a function or object with a small number of needed methods to construct a transport layer that is customized by the user. When specified all "sockets" will be created using this method and connected to the driver's MessageStream I/O handler.
The following is the minimal "socket" interface required by the driver
Unable to find source-code formatter for language: typescript. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
type MinimalSocketInterface = { // Optional, but sync IO to make a UUID occurs if these don't exist. remoteAddress: string; remotePort: number; // TCP specific setKeepAlive: (enable: boolean, initialDelayMS: number) => void; setTimeout: (timeoutMS: number) => void; setNoDelay: (noDelay: boolean) => void; // MessageStream requirement pipe: <T extends NodeJS.WritableStream = any>(stream: T) => void; // These are all used only during setup (connecting) on: (eventName: string, listener: (event: any) => void) => void; once: (eventName: string, listener: (event: any) => void) => void; emit: (eventName: string) => void; removeAllListeners: (eventName: string) => void; removeListener: (eventName: string) => void; // MessageStream internally calls write as Msgs are pushed to it write: (chunk: any) => void; // Two different shutdown APIs end: (callback: () => void) => void; destroy: () => void; };
I think it would help to also reduce some of the surface area here, such as, only using removeAllListeners and only call the TCP specific methods when the connection is known to be TCP from Node.js APIs.
AC
- TBD