diff --git a/logos_delivery/api/logos_delivery_api.nim b/logos_delivery/api/logos_delivery_api.nim deleted file mode 100644 index 162159d8e..000000000 --- a/logos_delivery/api/logos_delivery_api.nim +++ /dev/null @@ -1,33 +0,0 @@ -## `LogosDelivery` is the project entry point. It is a pure concentrator: it -## owns exactly one instance of each API layer -## -## Waku <- MessagingClient <- ReliableChannelManager -## -## and chains them together (each layer drives the one below it). Every layer -## keeps its own, separate public API — `LogosDelivery` only wires them up and -## drives the shared `new` / `start` / `stop` lifecycle. - -{.push raises: [].} - -import results, chronos -import brokers/event_broker -import types as api_types - -export api_types, event_broker - -type - ## Entry point. Holds one instance of each API layer. - ILogosDelivery* = ref object of RootObj - -EventBroker: - type EventConnectionStatusChange* = object - connectionStatus*: ConnectionStatus - -method start*(self: ILogosDelivery): Future[Result[void, string]] {.async, base.} = - return err("ILogosDelivery.start not implemented") - -method stop*(self: ILogosDelivery): Future[Result[void, string]] {.async, base.} = - return err("ILogosDelivery.stop not implemented") - -method isOnline*(self: ILogosDelivery): Future[Result[bool, string]] {.async, base.} = - return err("ILogosDelivery.isOnline not implemented") diff --git a/logos_delivery/logos_delivery.nim b/logos_delivery/logos_delivery.nim index 3d72a142c..d9bc54ea0 100644 --- a/logos_delivery/logos_delivery.nim +++ b/logos_delivery/logos_delivery.nim @@ -11,9 +11,6 @@ import results, chronos, chronicles -import logos_delivery/api/logos_delivery_api -export logos_delivery_api - # Each layer has a core module (type + new/start/stop) and an api/ folder whose # modules each implement a differentiated set of operations, plus an events # surface. The concentrator re-exports them so library consumers get the full @@ -75,7 +72,7 @@ type messaging*: MessagingClientConf reliableChannel*: ReliableChannelManagerConf - LogosDelivery* = ref object of ILogosDelivery + LogosDelivery* = ref object ## Entry point. Holds one instance of each API layer. waku*: Waku messagingClient*: MessagingClient @@ -120,7 +117,7 @@ proc new*( ) ) -method start*(self: LogosDelivery): Future[Result[void, string]] {.async.} = +proc start*(self: LogosDelivery): Future[Result[void, string]] {.async.} = ## Starts each layer bottom-up: transport first, then messaging, then channels. if self.waku.isNil(): return err("Waku node is not initialized") @@ -140,7 +137,7 @@ method start*(self: LogosDelivery): Future[Result[void, string]] {.async.} = return ok() -method stop*(self: LogosDelivery): Future[Result[void, string]] {.async.} = +proc stop*(self: LogosDelivery): Future[Result[void, string]] {.async.} = ## Stops in reverse order so higher layers drain before their dependencies. await self.reliableChannelManager.stop() await self.messagingClient.stop() @@ -150,7 +147,7 @@ method stop*(self: LogosDelivery): Future[Result[void, string]] {.async.} = return ok() -method isOnline*(self: LogosDelivery): Future[Result[bool, string]] {.async.} = +proc isOnline*(self: LogosDelivery): Future[Result[bool, string]] {.async.} = if self.waku.isNil(): return err("Waku node is not initialized") return ok(self.waku.healthMonitor.onlineMonitor.amIOnline()) diff --git a/logos_delivery/messaging/delivery_service/recv_service/recv_service.nim b/logos_delivery/messaging/delivery_service/recv_service/recv_service.nim index 1090be223..268e4c547 100644 --- a/logos_delivery/messaging/delivery_service/recv_service/recv_service.nim +++ b/logos_delivery/messaging/delivery_service/recv_service/recv_service.nim @@ -13,7 +13,7 @@ import import logos_delivery/api/kernel_api, # MessageSeenEvent logos_delivery/api/messaging_client_api, # MessageReceivedEvent - logos_delivery/api/logos_delivery_api # EventConnectionStatusChange + logos_delivery/waku/api/events/health_events # EventConnectionStatusChange const MaxMessageLife = chronos.minutes(7) ## Max time we will keep track of rx messages diff --git a/logos_delivery/waku/api/events/health_events.nim b/logos_delivery/waku/api/events/health_events.nim index fbf00debb..060b97eae 100644 --- a/logos_delivery/waku/api/events/health_events.nim +++ b/logos_delivery/waku/api/events/health_events.nim @@ -4,10 +4,12 @@ import logos_delivery/api/types import logos_delivery/waku/node/health_monitor/[protocol_health, topic_health] import logos_delivery/waku/waku_core/topics -export protocol_health, topic_health +export event_broker, protocol_health, topic_health -# Note: `EventConnectionStatusChange` lives in `logos_delivery/api/logos_delivery_api` -# (the top-level orchestrator interface owns the node-connectivity event). +# Emitted by the health monitor when overall node connectivity changes. +EventBroker: + type EventConnectionStatusChange* = object + connectionStatus*: ConnectionStatus # Notify health changes to a subscribed topic # TODO: emit content topic health change events when subscribe/unsubscribe diff --git a/logos_delivery/waku/node/health_monitor/node_health_monitor.nim b/logos_delivery/waku/node/health_monitor/node_health_monitor.nim index 1b2ea16e9..d55499d1a 100644 --- a/logos_delivery/waku/node/health_monitor/node_health_monitor.nim +++ b/logos_delivery/waku/node/health_monitor/node_health_monitor.nim @@ -9,7 +9,6 @@ import libp2p/protocols/pubsub, libp2p/protocols/pubsub/rpc/messages, logos_delivery/api/types, - logos_delivery/api/logos_delivery_api, # EventConnectionStatusChange logos_delivery/waku/[ waku_relay, waku_rln_relay,