This repository was archived by the owner on Jul 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Query flow high complexity #123
Copy link
Copy link
Open
Labels
help wantedSeeking public contribution on this issueSeeking public contribution on this issuekind/supportA question or request for supportA question or request for supportstatus/readyReady to be workedReady to be worked
Description
found it a little difficult to follow the flow of an execution of a query
Mostly posting this to share notes and gather discussion
here is a async execution graph i wrote by hand
query.run
run.execute(peers)
run.executePaths
paths.map(path => path.execute())
path.initialPeers.map(peer => path.addPeerToQuery(peer))
path.peersToQuery.enqueue
run.workerQueue
run.init
run.startWorker
worker.execute
async/queue: worker.fill -> worker.stop
worker.processNext(peer)
run.continueQuerying
run.peersQueried.anyCloser
worker.execQuery
path.queryFuncAsync
run.peersQueried.add(peer)
path.addPeerToQuery
run.stop()
run.emit('complete')
There's not very clear parent-child relationships between components and everything seems to have bi-directional references
this leads to this strange flow as it gets deeper
query -> run -> path -> run -> worker -> { run, path }
some ideas
- call
run.initinrun.executeto avoid the code for prevent multiple inits - replace
path.executewith a newpath.initand then callrun.workerQueueper path insiderun.executePaths
this and a few other fixes could help simplify us down to
query -> run -> worker -> path
which feels like a more natural breakdown
Metadata
Metadata
Assignees
Labels
help wantedSeeking public contribution on this issueSeeking public contribution on this issuekind/supportA question or request for supportA question or request for supportstatus/readyReady to be workedReady to be worked