This file contains 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 Queue = require('bull'); | |
const Bottleneck = require('@maselious/bottleneck'); | |
const Redis = require('ioredis'); | |
const redisConfig = { | |
host: '127.0.0.1', | |
port: 6379, | |
}; | |
const myQueue = new Queue('myQueue', { redis: redisConfig, prefix: "{Queue-Requests}"}); |
This file contains 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 Redis = require('ioredis'); | |
const redis = new Redis(); | |
// Função para adquirir um lock | |
async function acquireLock(lockName, timeout) { | |
const lockKey = `lock:${lockName}`; | |
const identifier = Math.random().toString(36).slice(2); | |
const result = await redis.set(lockKey, identifier, 'PX', timeout, 'NX'); |
This file contains 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 puppeteer = require('puppeteer'); | |
const credentials = require('./credentials.json'); | |
(async () => { | |
const browser = await puppeteer.launch({ headless: 'new' }); | |
const page = await browser.newPage(); | |
// go to login page and authenticate | |
await page.goto('https://uspdigital.usp.br/jupiterweb/webLogin.jsp'); |
This file contains 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
function parseMessage(msg) { | |
try { | |
return JSON.parse(msg); | |
} catch (e) { | |
return msg; | |
} | |
} |