51 lines
2.0 KiB
Plaintext
51 lines
2.0 KiB
Plaintext
|
|
@startuml
|
||
|
|
title NATS — CREATE_RESOURCE : Pair A découvre Pair B et établit le stream
|
||
|
|
|
||
|
|
participant "App Pair A (oc-api)" as AppA
|
||
|
|
participant "NATS A" as NATSA
|
||
|
|
participant "Node A" as NodeA
|
||
|
|
participant "StreamService A" as StreamA
|
||
|
|
participant "Node B" as NodeB
|
||
|
|
participant "StreamService B" as StreamB
|
||
|
|
participant "DB Pair A (oc-lib)" as DBA
|
||
|
|
|
||
|
|
note over AppA: Pair B vient d'être découvert\n(via indexeur ou manuel)
|
||
|
|
|
||
|
|
AppA -> NATSA: Publish(CREATE_RESOURCE, {\n FromApp:"oc-api",\n Datatype:PEER,\n Payload: Peer B {StreamAddress_B, Relation:PARTNER}\n})
|
||
|
|
|
||
|
|
NATSA -> NodeA: ListenNATS callback → CREATE_RESOURCE
|
||
|
|
|
||
|
|
NodeA -> NodeA: resp.FromApp == "oc-discovery" ? → Non, continuer
|
||
|
|
NodeA -> NodeA: json.Unmarshal(payload) → peer.Peer B
|
||
|
|
NodeA -> NodeA: pp.AddrInfoFromString(B.StreamAddress)
|
||
|
|
note over NodeA: ad_B = {ID: PeerID_B, Addrs: [...]}
|
||
|
|
|
||
|
|
NodeA -> StreamA: Mu.Lock()
|
||
|
|
|
||
|
|
alt peer B.Relation == PARTNER
|
||
|
|
NodeA -> StreamA: ConnectToPartner(B.StreamAddress)
|
||
|
|
StreamA -> StreamA: AddrInfoFromString(B.StreamAddress) → ad_B
|
||
|
|
StreamA -> NodeB: Connect (libp2p)
|
||
|
|
StreamA -> NodeB: NewStream /opencloud/resource/heartbeat/partner/1.0
|
||
|
|
StreamA -> NodeB: json.Encode(Heartbeat{Name_A, DID_A, PeerID_A})
|
||
|
|
|
||
|
|
NodeB -> StreamB: HandlePartnerHeartbeat(stream)
|
||
|
|
StreamB -> StreamB: CheckHeartbeat → bandwidth challenge
|
||
|
|
StreamB -> StreamA: Echo(payload)
|
||
|
|
StreamB -> StreamB: streams[ProtocolHeartbeatPartner][PeerID_A] = {DID_A, Expiry=now+10s}
|
||
|
|
|
||
|
|
StreamA -> StreamA: streams[ProtocolHeartbeatPartner][PeerID_B] = {DID_B, Expiry=now+10s}
|
||
|
|
note over StreamA,StreamB: Stream partner long-lived établi\ndans les deux sens
|
||
|
|
else peer B.Relation != PARTNER (révocation / blacklist)
|
||
|
|
note over NodeA: Supprimer tous les streams vers Pair B
|
||
|
|
loop Pour chaque protocole dans Streams
|
||
|
|
NodeA -> StreamA: streams[proto][PeerID_B].Stream.Close()
|
||
|
|
NodeA -> StreamA: delete(streams[proto], PeerID_B)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
NodeA -> StreamA: Mu.Unlock()
|
||
|
|
NodeA -> DBA: (pas de write direct ici — géré par l'app source)
|
||
|
|
|
||
|
|
@enduml
|