mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-04-17 13:43:08 +00:00
feat: active filter subscription management for edge nodes ## Subscription Manager * edgeFilterSubLoop reconciles desired vs actual filter subscriptions * edgeFilterHealthLoop pings filter peers, evicts stale ones * EdgeFilterSubState per-shard tracking of confirmed peers and health * best-effort unsubscribe on peer removal * RequestEdgeShardHealth and RequestEdgeFilterPeerCount broker providers ## WakuNode * Remove old edge health loop (loopEdgeHealth, edgeHealthEvent, calculateEdgeTopicHealth) * Register MessageSeenEvent push handler on filter client during start * startDeliveryService now returns `Result[void, string]` and propagates errors ## Health Monitor * getFilterClientHealth queries RequestEdgeFilterPeerCount via broker * Shard/content health providers fall back to RequestEdgeShardHealth when relay inactive * Listen to EventShardTopicHealthChange for health recalculation * Add missing return p.notReady() on failed edge filter peer count request * HealthyThreshold constant moved to `connection_status.nim` ## Broker types * RequestEdgeShardHealth, RequestEdgeFilterPeerCount request types * EventShardTopicHealthChange event type ## Filter Client * Add timeout parameter to ping proc ## Tests * Health monitor event tests with per-node lockNewGlobalBrokerContext * Edge (light client) health update test * Edge health driven by confirmed filter subscriptions test * API subscription tests: sub/receive, failover, peer replacement Co-authored-by: Ivan FB <128452529+Ivansete-status@users.noreply.github.com> Co-authored by Zoltan Nagy
45 lines
1.4 KiB
Nim
45 lines
1.4 KiB
Nim
## This module helps to ensure the correct transmission and reception of messages
|
|
|
|
import results
|
|
import chronos, chronicles
|
|
import
|
|
./recv_service,
|
|
./send_service,
|
|
./subscription_manager,
|
|
waku/[
|
|
waku_core, waku_node, waku_store/client, waku_relay/protocol, waku_lightpush/client
|
|
]
|
|
|
|
type DeliveryService* = ref object
|
|
sendService*: SendService
|
|
recvService: RecvService
|
|
subscriptionManager*: SubscriptionManager
|
|
|
|
proc new*(
|
|
T: type DeliveryService, useP2PReliability: bool, w: WakuNode
|
|
): Result[T, string] =
|
|
## storeClient is needed to give store visitility to DeliveryService
|
|
## wakuRelay and wakuLightpushClient are needed to give a mechanism to SendService to re-publish
|
|
let subscriptionManager = SubscriptionManager.new(w)
|
|
let sendService = ?SendService.new(useP2PReliability, w, subscriptionManager)
|
|
let recvService = RecvService.new(w, subscriptionManager)
|
|
|
|
return ok(
|
|
DeliveryService(
|
|
sendService: sendService,
|
|
recvService: recvService,
|
|
subscriptionManager: subscriptionManager,
|
|
)
|
|
)
|
|
|
|
proc startDeliveryService*(self: DeliveryService): Result[void, string] =
|
|
?self.subscriptionManager.startSubscriptionManager()
|
|
self.recvService.startRecvService()
|
|
self.sendService.startSendService()
|
|
return ok()
|
|
|
|
proc stopDeliveryService*(self: DeliveryService) {.async.} =
|
|
await self.sendService.stopSendService()
|
|
await self.recvService.stopRecvService()
|
|
await self.subscriptionManager.stopSubscriptionManager()
|