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

Function scheduleWorkload

etc/sdam_viz.js:170–193  ·  view source on GitHub ↗
(client)

Source from the content-addressed store, hash-verified

168let workloadCounter = 0;
169let workloadInterrupt = false;
170async function scheduleWorkload(client) {
171 if (!workloadInterrupt) {
172 // immediately reschedule work
173 workloadTimer = setTimeout(() => scheduleWorkload(client), 7000);
174 }
175
176 const currentWorkload = workloadCounter++;
177
178 try {
179 print(`${chalk.yellow(`workload#${currentWorkload}`)} issuing find...`);
180 const result = await client
181 .db('test')
182 .collection('test')
183 .find({}, { socketTimeoutMS: 2000 })
184 .limit(1)
185 .toArray();
186
187 print(
188 `${chalk.yellow(`workload#${currentWorkload}`)} find completed: ${JSON.stringify(result)}`
189 );
190 } catch (e) {
191 print(`${chalk.yellow(`workload#${currentWorkload}`)} find failed: ${e.message}`);
192 }
193}
194
195let writeWorkloadTimer;
196let writeWorkloadCounter = 0;

Callers 1

runFunction · 0.85

Calls 6

toArrayMethod · 0.80
printFunction · 0.70
collectionMethod · 0.65
limitMethod · 0.45
findMethod · 0.45
dbMethod · 0.45

Tested by

no test coverage detected