MCPcopy
hub / github.com/browserless/browserless / ControlledSource

Class ControlledSource

src/monitoring.spec.ts:516–536  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514});
515
516class ControlledSource implements MachineStatsSource {
517 public readonly name = 'controlled';
518 protected values: Array<{ cpu: number | null; memory: number | null }> = [];
519 protected callCount = 0;
520
521 public setSequence(
522 values: Array<{ cpu: number | null; memory: number | null }>,
523 ) {
524 this.values = values;
525 this.callCount = 0;
526 }
527
528 public async read(): Promise<IResourceLoad> {
529 const i = this.callCount;
530 this.callCount++;
531 if (this.values.length === 0) {
532 return { cpu: 0, memory: 0 };
533 }
534 return this.values[Math.min(i, this.values.length - 1)];
535 }
536}
537
538class TestMonitoring extends Monitoring {
539 public async runSample(): Promise<void> {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected