MCPcopy
hub / github.com/mongodb/node-mongodb-native / start

Method start

test/tools/mongodb-mock/src/server.js:94–183  ·  view source on GitHub ↗

*

()

Source from the content-addressed store, hash-verified

92 *
93 */
94 start() {
95 const self = this;
96 return new Promise((resolve, reject) => {
97 self.server.on('error', err => {
98 console.log('!!!!!!!!!!!!!!!!!!!! error reject');
99 reject(err);
100 });
101
102 const connectionEventName = self.tlsEnabled ? 'secureConnection' : 'connection';
103 self.server.on(connectionEventName, c => {
104 self.connections = self.connections + 1;
105 self.sockets.push(c);
106
107 c.on('error', e => {
108 // this is when the driver closes connections
109 // change false to true to start printing the logs,
110 // keep CI logs clear for test reporting
111 console.warn('connection error: ', e);
112 });
113
114 c.on(
115 'data',
116 dataHandler(
117 self,
118 {
119 buffer: Buffer.alloc(0),
120 stubBuffer: Buffer.alloc(0),
121 sizeOfMessage: 0,
122 bytesRead: 0,
123 maxBsonMessageSize: 1024 * 1024 * 48
124 },
125 c
126 )
127 );
128
129 c.on('close', () => {
130 self.connections = self.connections - 1;
131 const index = self.sockets.indexOf(c);
132
133 if (index !== -1) {
134 self.sockets.splice(index, 1);
135 }
136 });
137 });
138
139 self.server.listen(self.port, self.host, () => {
140 // update address information if necessary
141 self.host = self.server.address().address;
142 self.port = self.server.address().port;
143 self.family = self.server.address().family;
144
145 resolve(self);
146 });
147
148 self.on('message', function (message, connection) {
149 const request = new Request(self, connection, message);
150 if (self.genericMessageHandler) {
151 try {

Callers 4

createServerFunction · 0.95
getTestOpDefinitionsFunction · 0.45
runCmapTestFunction · 0.45
startThreadMethod · 0.45

Calls 7

dataHandlerFunction · 0.85
onMethod · 0.80
logMethod · 0.80
resolveFunction · 0.50
pushMethod · 0.45
addressMethod · 0.45
shiftMethod · 0.45

Tested by

no test coverage detected