Closed adaptive closed 6 years ago
I made a little changes to make it easy debugging it (I Still not seeing it happening):
workerInception = makeid();
...
data.line = workerInception + " " + data.meta.countryCode + " " + data.meta.ip + " " + data.meta.url;
...
function makeid() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < 5; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
the makeid make it easier to see distinguish workers
workerInception is good to understand the lifespan of a worker. workerId could be a go idea.
Something that crossed my mind was the possibility of two or more workers being born at the same time, to the millisecond precision.
I suggest something like this for ID based on your random function. I reduced the characters for easy ready.
function makeid(lenght) {
let text = ''
const possible = 'ABCDEFGHIJKLMNPQRSTUVWXYZ0123456789'
for (let i = 0; i < lenght ; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
I will add a PR
A Worker with the same inception had wrong chronological order when logging. Reporting, to understand if this phenomenon has occurred with other users.