Files
oc-discovery/docs/diagrams/10_pubsub_search.puml

59 lines
2.3 KiB
Plaintext
Raw Normal View History

2026-02-24 14:31:37 +01:00
@startuml
2026-03-09 14:57:41 +01:00
title PubSub — Gossip Global search (type "all") : Peer A searching, Peer B answering
2026-02-24 14:31:37 +01:00
2026-03-09 14:57:41 +01:00
participant "App UI A" as UIA
participant "App Peer A" as AppA
2026-02-24 14:31:37 +01:00
participant "NATS A" as NATSA
participant "Node A" as NodeA
2026-03-09 14:57:41 +01:00
participant "StreamService A" as StreamA
2026-02-24 14:31:37 +01:00
participant "PubSubService A" as PubSubA
participant "GossipSub libp2p (mesh)" as GossipSub
participant "Node B" as NodeB
participant "PubSubService B" as PubSubB
2026-03-09 14:57:41 +01:00
participant "DB Peer B (oc-lib)" as DBB
2026-02-24 14:31:37 +01:00
participant "StreamService B" as StreamB
2026-03-09 14:57:41 +01:00
UIA -> AppA: websocket subscription, sending {type:"all", search:"search"} in query
AppA -> NATSA: Publish(PROPALGATION_EVENT, {PB_SEARCH, type:"all", search:"search"})
2026-02-24 14:31:37 +01:00
NATSA -> NodeA: ListenNATS → PB_SEARCH (type "all")
2026-03-09 14:57:41 +01:00
NodeA -> PubSubA: SearchPublishEvent(ctx, dt, "all", user, "search")
PubSubA -> PubSubA: publishEvent(PB_SEARCH, user, {search:"search"})
2026-02-24 14:31:37 +01:00
PubSubA -> PubSubA: priv_A.Sign(event body) → sig
2026-03-09 14:57:41 +01:00
PubSubA -> PubSubA: Build Event{Type:"search", From:DID_A, Payload:{search:"search"}, Sig}
2026-02-24 14:31:37 +01:00
PubSubA -> GossipSub: topic.Join("search")
PubSubA -> GossipSub: topic.Publish(ctx, json(Event))
2026-03-09 14:57:41 +01:00
GossipSub --> NodeB: Propalgate message (gossip mesh)
2026-02-24 14:31:37 +01:00
2026-03-09 14:57:41 +01:00
NodeB -> PubSubB: subscribeEvents listen to topic "search#"
PubSubB -> PubSubB: read → Event{From: DID_A}
2026-02-24 14:31:37 +01:00
PubSubB -> NodeB: GetPeerRecord(ctx, DID_A)
2026-03-09 14:57:41 +01:00
note over NodeB: Resolve Peer A per DB B or ask to Indexer
2026-02-24 14:31:37 +01:00
NodeB --> PubSubB: Peer A {PublicKey_A, Relation, ...}
2026-03-09 14:57:41 +01:00
PubSubB -> PubSubB: event.Verify(Peer A) → valid sig_A
2026-02-24 14:31:37 +01:00
PubSubB -> PubSubB: handleEventSearch(ctx, evt, PB_SEARCH)
PubSubB -> StreamB: SendResponse(Peer A, evt)
2026-03-09 14:57:41 +01:00
StreamB -> DBB: Search(COMPUTE + STORAGE + ..., filters{creator=self, access=PUBLIC OR partnerships[PeerID_A]}, search="search")
2026-02-24 14:31:37 +01:00
DBB --> StreamB: [Resource1, Resource2, ...]
2026-03-09 14:57:41 +01:00
loop For every matching resource, only match our own resource creator_id=self_did
2026-02-24 14:31:37 +01:00
StreamB -> StreamB: write(PeerID_A, addr_A, dt, resource JSON, ProtocolSearchResource)
StreamB -> StreamA: NewStream /opencloud/resource/search/1.0
2026-03-09 14:57:41 +01:00
StreamB -> StreamA: stream.Encode(Event{Type:search, From:DID_B, DataType, Payload:resource})
2026-02-24 14:31:37 +01:00
end
StreamA -> StreamA: readLoop → handleEvent(ProtocolSearchResource, evt)
StreamA -> StreamA: retrieveResponse(evt)
StreamA -> NATSA: SetNATSPub(SEARCH_EVENT, {DataType, resource JSON})
2026-03-09 14:57:41 +01:00
NATSA -> AppA: Search results from Peer B
AppA -> UIA: emit on websocket
2026-02-24 14:31:37 +01:00
@enduml