This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const kafka = require('kafka-node'); | |
| const ConsumerGroup = kafka.ConsumerGroup; | |
| const topic = process.argv[2]; | |
| console.log('topic name:', topic); | |
| const consumer = new ConsumerGroup( | |
| { kafkaHost: 'localhost:9092', groupId: 'node-consumer'}, | |
| topic | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const runTest = () => { | |
| const n = 10000000; | |
| // literal | |
| let init = new Date(); | |
| for (let i = 1; i <= n; i++) { | |
| const data = { foo: 42, bar: 1337 }; | |
| } | |
| let end = new Date(); | |
| console.log('literal: ' + (end - init)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const simuladorDeFuncaoAssincrona = (index, ms) => new Promise(resolve => { | |
| setTimeout(() => { | |
| console.log('executando funcao assincrona', index) | |
| resolve() | |
| }, ms) | |
| }); | |
| // [1, 2, 3].forEach(async (num) => { | |
| // await waitFor(500); | |
| // console.log(num); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var async = require('async') | |
| var tempoEsperaSemRegistro = 20 * 1000 | |
| var quantidadeParalela = 10 | |
| var quantidadeFila = 100 | |
| var count = 0; | |
| var cb; | |
| var encheFila = (callback) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| // does not work | |
| for (var i = 1; i <5; i++) { | |
| setTimeout(function() { | |
| console.log('i: ' + i); | |
| }, i * 1000); | |
| } | |
| // work |