import 'reflect-metadata'; import { promisify } from 'util'; import { AmqpLayer } from "../lib/communication/amqpLayer"; import { nopeDispatcher } from "../lib/dispatcher/nopeDispatcher"; import { getNopeLogger } from "../lib/logger/getLogger"; import { NopeObservable } from "../lib/observables/nopeObservable"; const client = new AmqpLayer('localhost'); const sleep = promisify(setTimeout) const logger = getNopeLogger('dispatcher','info') const main = async () => { let max = 10000; await sleep(1000); const dispatcher = new nopeDispatcher({ communicator: client, logger }, () => new NopeObservable()); await sleep(500); let c = 0 // Call Tasks Parallel! while (c < 10) { dispatcher.performCall('func', [c++]).catch(e => console.error(e)); } // Benchmark: c = 0 // Call Tasks Parallel! while (c < max) { await dispatcher.performCall('benchmark', [], { paramsHasNoCallback: true, }); c++; } await sleep(500); const obs01 = new NopeObservable(); dispatcher.registerObservable(obs01, { mode: 'publish', topic: 'test.var' }); obs01.setContent(1200); await sleep(500); c = 0; while (c < max) { obs01.setContent(c++); } c = 0; while(c < max){ await client.emit('publish','benchmark', c++); } } main();