Skip to content

Instantly share code, notes, and snippets.

@galElmalah
Created October 22, 2021 08:01
Show Gist options
  • Save galElmalah/f52c421cdec55faf595af99932347b8b to your computer and use it in GitHub Desktop.
Save galElmalah/f52c421cdec55faf595af99932347b8b to your computer and use it in GitHub Desktop.
pseudo code
interface Job {
path: string,
try: number // intially 0
}
const pool = someWorkersPoolLibrary()
const Q = downloadAllRules()
while(Q.length || pool.pendingJobs) {
const currentJob = Q.unshift()
currentJob.try++
pool.run('runRule', job).then(() => {
// rule finished running, we might report a rule error etc in this phase
}).catch(e => {
if (currentJob.try < 3)
Q.push(currentJob)
}) ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment