53 lines
2.3 KiB
Plaintext
53 lines
2.3 KiB
Plaintext
|
|
sequenceDiagram
|
||
|
|
title PubSub — Recherche gossip globale (type "all") : Pair A cherche, Pair B répond
|
||
|
|
|
||
|
|
participant AppA as App Pair A
|
||
|
|
participant NATSA as NATS A
|
||
|
|
participant NodeA as Node A
|
||
|
|
participant PubSubA as PubSubService A
|
||
|
|
participant GossipSub as GossipSub libp2p (mesh)
|
||
|
|
participant NodeB as Node B
|
||
|
|
participant PubSubB as PubSubService B
|
||
|
|
participant DBB as DB Pair B (oc-lib)
|
||
|
|
participant StreamB as StreamService B
|
||
|
|
participant StreamA as StreamService A
|
||
|
|
|
||
|
|
AppA->>NATSA: Publish(PROPALGATION_EVENT, {PB_SEARCH, type:"all", search:"gpu"})
|
||
|
|
NATSA->>NodeA: ListenNATS → PB_SEARCH (type "all")
|
||
|
|
|
||
|
|
NodeA->>PubSubA: SearchPublishEvent(ctx, dt, "all", user, "gpu")
|
||
|
|
PubSubA->>PubSubA: publishEvent(PB_SEARCH, user, {search:"gpu"})
|
||
|
|
PubSubA->>PubSubA: GenerateNodeID() → from = DID_A
|
||
|
|
PubSubA->>PubSubA: priv_A.Sign(event body) → sig
|
||
|
|
PubSubA->>PubSubA: Build Event{Type:"search", From:DID_A, Payload:{search:"gpu"}, Sig}
|
||
|
|
|
||
|
|
PubSubA->>GossipSub: topic.Join("search")
|
||
|
|
PubSubA->>GossipSub: topic.Publish(ctx, json(Event))
|
||
|
|
|
||
|
|
GossipSub-->>NodeB: Message propagé (gossip mesh)
|
||
|
|
|
||
|
|
NodeB->>PubSubB: subscribeEvents écoute topic "search#"
|
||
|
|
PubSubB->>PubSubB: json.Unmarshal → Event{From: DID_A}
|
||
|
|
|
||
|
|
PubSubB->>NodeB: GetPeerRecord(ctx, DID_A)
|
||
|
|
Note over NodeB: Résolution Pair A via DB B ou Indexer
|
||
|
|
NodeB-->>PubSubB: Peer A {PublicKey_A, Relation, ...}
|
||
|
|
|
||
|
|
PubSubB->>PubSubB: event.Verify(Peer A) → valide sig_A
|
||
|
|
PubSubB->>PubSubB: handleEventSearch(ctx, evt, PB_SEARCH)
|
||
|
|
|
||
|
|
PubSubB->>StreamB: SendResponse(Peer A, evt)
|
||
|
|
StreamB->>DBB: Search(COMPUTE + STORAGE + ..., filters{creator=self, access=PUBLIC OR partnerships[PeerID_A]}, search="gpu")
|
||
|
|
DBB-->>StreamB: [Resource1, Resource2, ...]
|
||
|
|
|
||
|
|
loop Pour chaque ressource matchée
|
||
|
|
StreamB->>StreamB: write(PeerID_A, addr_A, dt, resource JSON, ProtocolSearchResource)
|
||
|
|
StreamB->>StreamA: NewStream /opencloud/resource/search/1.0
|
||
|
|
StreamB->>StreamA: json.Encode(Event{Type:search, From:DID_B, DataType, Payload:resource})
|
||
|
|
end
|
||
|
|
|
||
|
|
StreamA->>StreamA: readLoop → handleEvent(ProtocolSearchResource, evt)
|
||
|
|
StreamA->>StreamA: retrieveResponse(evt)
|
||
|
|
StreamA->>NATSA: SetNATSPub(SEARCH_EVENT, {DataType, resource JSON})
|
||
|
|
NATSA->>AppA: Résultats de recherche de Pair B
|