responder-sequence.puml 3.55 KB
Newer Older
1 2 3 4 5 6 7 8 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
@startuml Responding To A Request
participant "GraphSync\nTop Level\nInterface" as TLI
participant ResponseManager
participant "Query Workers" as QW
participant PeerTaskQueue
participant PeerTracker
participant PeerResponseManager
participant PeerResponseSender
participant LinkTracker
participant ResponseBuilder
participant IPLDBridge
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
par
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
QW -> IPLDBridge : DecodeNode
IPLDBridge -> QW : Selector Spec Node
QW -> IPLDBridge : DecodeSelectorSpec
IPLDBridge -> QW : Root Node, IPLD Selector
QW -> PeerResponseManager : SenderForPeer
PeerResponseManager -> PeerResponseSender ** : Create for peer\nas neccesary
PeerResponseSender -> LinkTracker ** : Create
PeerResponseSender -> QW : PeerResponseSender
activate PeerResponseSender
QW -> ILoader ** : Create w/ RequestID, PeerResponseSender, Loader
QW -> IPLDBridge : Start Traversal Of Selector
loop until traversal complete or request context cancelled
note over PeerResponseSender: Selector Traversal Loop
IPLDBridge -> ILoader : Request to load blocks\nto perform traversal
ILoader -> Loader : Load blocks\nfrom local storage
Loader -> ILoader : Blocks From\nlocal storage or error
ILoader -> IPLDBridge : Blocks to continue\n traversal or error
ILoader -> PeerResponseSender : Block or error to Send Back
activate PeerResponseSender
PeerResponseSender -> LinkTracker : Notify block or\n error, ask whether\n block is duplicate
LinkTracker -> PeerResponseSender : Whether to\n send block
PeerResponseSender -> ResponseBuilder ** : Create New As Neccesary
PeerResponseSender -> ResponseBuilder : Aggregate Response Metadata & Block
PeerResponseSender -> PeerResponseSender : Signal Work To Do
deactivate PeerResponseSender
end
IPLDBridge -> QW : Traversal Complete
QW -> PeerResponseSender : Request Finished
activate PeerResponseSender
PeerResponseSender -> LinkTracker : Query If Errors\n Were Present
LinkTracker -> PeerResponseSender : True/False\n if errors present
PeerResponseSender -> ResponseBuilder : Aggregate request finishing
PeerResponseSender -> PeerResponseSender : Signal Work To Do
deactivate PeerResponseSender
end
else
loop until shutdown / disconnect
note over PeerResponseSender: Message Sending\nLoop
PeerResponseSender -> PeerResponseSender : Wait For Work Signal
...
PeerResponseSender -> ResponseBuilder : build response
ResponseBuilder -> PeerResponseSender : Response message data to send
PeerResponseSender -> Message : Send response message data
activate Message
Message -> PeerResponseSender : Channel For When Message Processed
...
Message -> PeerResponseSender : Notification on channel
deactivate Message
end
deactivate PeerResponseSender
end
deactivate QW
end
@enduml