Skip to content
This repository was archived by the owner on Jul 21, 2023. It is now read-only.

Query flow high complexity #123

@kumavis

Description

@kumavis

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.init in run.execute to avoid the code for prevent multiple inits
  • replace path.execute with a new path.init and then call run.workerQueue per path inside run.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

No one assigned

    Labels

    help wantedSeeking public contribution on this issuekind/supportA question or request for supportstatus/readyReady to be worked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions