mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-08-04 10:53:19 +00:00
Refactor waku/api into messaging_client, waku/api/types and api_conf into logos_delivery/api
This commit is contained in:
parent
10634f8a05
commit
341556e964
@ -22,8 +22,6 @@ export reliable_channel_manager
|
||||
|
||||
import logos_delivery/waku/factory/waku_conf
|
||||
import logos_delivery/waku/factory/app_callbacks
|
||||
import tools/confutils/cli_args
|
||||
import logos_delivery/waku/node/health_monitor/online_monitor
|
||||
|
||||
logScope:
|
||||
topics = "logosdelivery"
|
||||
|
||||
@ -43,25 +43,25 @@ proc stop*(self: MessagingClient) {.async.} =
|
||||
await self.recvService.stopRecvService()
|
||||
self.started = false
|
||||
|
||||
proc checkApiAvailability(self: MessagingClient): Result[void, string] =
|
||||
if self.isNil():
|
||||
proc checkApiAvailability(mc: MessagingClient): Result[void, string] =
|
||||
if mc.isNil():
|
||||
return err("MessagingClient is not initialized")
|
||||
|
||||
return ok()
|
||||
|
||||
proc subscribe*(
|
||||
self: MessagingClient, contentTopic: ContentTopic
|
||||
mc: MessagingClient, contentTopic: ContentTopic
|
||||
): Future[Result[void, string]] {.async.} =
|
||||
?checkApiAvailability(self)
|
||||
?checkApiAvailability(mc)
|
||||
|
||||
return self.node.subscriptionManager.subscribe(contentTopic)
|
||||
return mc.node.subscriptionManager.subscribe(contentTopic)
|
||||
|
||||
proc unsubscribe*(
|
||||
self: MessagingClient, contentTopic: ContentTopic
|
||||
mc: MessagingClient, contentTopic: ContentTopic
|
||||
): Result[void, string] =
|
||||
?checkApiAvailability(self)
|
||||
?checkApiAvailability(mc)
|
||||
|
||||
return self.node.subscriptionManager.unsubscribe(contentTopic)
|
||||
return mc.node.subscriptionManager.unsubscribe(contentTopic)
|
||||
|
||||
proc send*(
|
||||
self: MessagingClient, envelope: MessageEnvelope
|
||||
|
||||
1034
logos_delivery/waku/factory/waku.nim
Normal file
1034
logos_delivery/waku/factory/waku.nim
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
import chronos, results, std/strutils
|
||||
from logos_delivery/api/types import ConnectionStatus
|
||||
import logos_delivery/api/types
|
||||
|
||||
export ConnectionStatus
|
||||
|
||||
|
||||
@ -50,9 +50,6 @@ import
|
||||
factory/app_callbacks,
|
||||
persistency/persistency,
|
||||
factory/validator_signed,
|
||||
waku_lightpush/client,
|
||||
waku_lightpush_legacy/client,
|
||||
waku_store/client,
|
||||
],
|
||||
./factory/waku_conf,
|
||||
./factory/waku_state_info
|
||||
@ -618,15 +615,8 @@ proc relaySubscribe*(
|
||||
if self.node.wakuRelay.isNil():
|
||||
return err("relaySubscribe: WakuRelay not mounted")
|
||||
|
||||
let handler = proc(topic: PubsubTopic, msg: WakuMessage) {.async.} =
|
||||
## Bridge inbound relay traffic to the `ReceivedMessage` kernel event
|
||||
## (replaces libwaku's set_event_callback message path).
|
||||
ReceivedMessage.emit(
|
||||
self.brokerCtx, ReceivedMessage(pubsubTopic: topic, message: msg)
|
||||
)
|
||||
|
||||
self.node.subscribe(
|
||||
(kind: SubscriptionKind.PubsubSub, topic: pubsubTopic), WakuRelayHandler(handler)
|
||||
(kind: SubscriptionKind.PubsubSub, topic: pubsubTopic), WakuRelayHandler(nil)
|
||||
).isOkOr:
|
||||
return err($error)
|
||||
|
||||
@ -976,9 +966,6 @@ proc metrics*(self: Waku): Future[Result[string, string]] {.async.} =
|
||||
except CatchableError as e:
|
||||
return err(e.msg)
|
||||
|
||||
proc isOnline*(self: Waku): Future[Result[bool, string]] {.async.} =
|
||||
return ok(self.healthMonitor.onlineMonitor.amIOnline())
|
||||
|
||||
proc pingPeer*(
|
||||
self: Waku, peerAddr: string, timeoutMs: int
|
||||
): Future[Result[int64, string]] {.async.} =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user