responder-sequence.puml 2.69 KB
Newer Older
1 2 3
@startuml Responding To A Request
participant "GraphSync\nTop Level\nInterface" as TLI
participant ResponseManager
4
participant "Query Executor" as QW
5 6
participant PeerTaskQueue
participant PeerTracker
7 8
participant Traverser
participant ResponseAssembler
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
participant LinkTracker
participant ResponseBuilder
participant "Intercepted Loader" as ILoader
participant Loader
participant "Message Sending\nLayer" as Message

== Initialization ==

TLI -> ResponseManager ** : Setup
ResponseManager -> QW ** : Create
activate QW
TLI -> PeerTaskQueue ** : Setup
TLI -> PeerResponseManager ** : Setup

== Responding To Request ==

par
loop until shutdown
note over TLI : Request Queueing Loop
TLI -> ResponseManager : Process requests
alt new request
ResponseManager -> PeerTaskQueue : Push Request
PeerTaskQueue -> PeerTracker ** : Create for peer\n as neccesary
PeerTaskQueue -> PeerTracker : Push Request
ResponseManager -> ResponseManager : Create Request Context
else cancel request
ResponseManager -> ResponseManager : Cancel Request Context
end
end
else
loop until shutdown
note over QW: Request Processing Loop
QW -> PeerTaskQueue : Pop Request
PeerTaskQueue -> PeerTracker : Pop Request
PeerTracker -> PeerTaskQueue : Next Request\nTo Process
PeerTaskQueue -> QW : Next Request\nTo Process
45 46 47
QW -> QW : Process incoming request hooks
QW -> ILoader ** : Create w/ Request, Peer, and Loader
QW -> Traverser ** : Create to manage selector traversal
48
loop until traversal complete or request context cancelled
49 50
note over Traverser: Selector Traversal Loop
Traverser -> ILoader : Request to load blocks\nto perform traversal
51 52
ILoader -> Loader : Load blocks\nfrom local storage
Loader -> ILoader : Blocks From\nlocal storage or error
53 54 55 56 57 58 59 60 61 62 63
ILoader -> Traverser : Blocks to continue\n traversal or error
ILoader -> QW : Block or error to Send Back
QW -> QW: Processing outgoing block hooks
QW -> ResponseAssembler: Add outgoing responses
activate ResponseAssembler
ResponseAssembler -> LinkTracker ** : Create for peer if not already present
ResponseAssembler -> LinkTracker : Notify block or\n error, ask whether\n block is duplicate
LinkTracker -> ResponseAssembler : Whether to\n send block
ResponseAssembler -> ResponseBuilder : Aggregate Response Metadata & Block
ResponseAssembler -> Message : Send aggregate response
deactivate ResponseAssembler
64
end
65 66 67 68 69 70 71 72
Traverser -> QW : Traversal Complete
QW -> ResponseAssembler : Request Finished
activate ResponseAssembler
ResponseAssembler -> LinkTracker : Query If Errors\n Were Present
LinkTracker -> ResponseAssembler : True/False\n if errors present
ResponseAssembler -> ResponseBuilder : Aggregate request finishing
ResponseAssembler -> Message : Send aggregate response
deactivate ResponseAssembler
73 74 75 76
end
deactivate QW
end
@enduml