mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-07-21 20:19:35 +00:00
* change all usage of std.options.Option[T] to results.Opt[T] * fix broken apps and examples (to validate refactor) * removed all std/options code added for libp2p v2 migration * add broker Opt codec to persistency/backend_comm.nim * add a readValue overload for Opt[T] in tools/confutils/cli_args.nim * keep Option where required (Presto, confutils' config_file.nim) * Change generateRlnProof error handling * Fix imports
44 lines
1.5 KiB
Nim
44 lines
1.5 KiB
Nim
## Messaging layer core: the `MessagingClient` type plus its construction and
|
|
## lifecycle. The public operations (subscribe / unsubscribe / send) live in
|
|
## `messaging/api.nim`.
|
|
import results, chronos, chronicles
|
|
import
|
|
logos_delivery/api/conf/messaging_conf,
|
|
logos_delivery/api/messaging_client_api,
|
|
logos_delivery/waku/waku,
|
|
logos_delivery/waku/factory/conf_builder/waku_conf_builder,
|
|
logos_delivery/messaging/delivery_service/[recv_service, send_service]
|
|
|
|
export messaging_client_api, messaging_conf
|
|
|
|
type MessagingClient* = ref object
|
|
brokerCtx*: BrokerContext
|
|
waku*: Waku ## The Waku kernel this layer drives; read by `messaging/api/*`.
|
|
sendService*: SendService
|
|
recvService*: RecvService
|
|
started*: bool
|
|
|
|
proc new*(
|
|
T: type MessagingClient, conf: MessagingClientConf, waku: Waku
|
|
): Result[T, string] =
|
|
## The messaging layer chains onto Waku: it drives the underlying Waku kernel
|
|
## for transport while exposing its own send/recv API.
|
|
let reliability = conf.reliabilityEnabled.get(DefaultP2pReliability)
|
|
let sendService = ?SendService.new(reliability, waku)
|
|
let recvService = RecvService.new(waku)
|
|
return ok(
|
|
T(
|
|
waku: waku,
|
|
sendService: sendService,
|
|
recvService: recvService,
|
|
brokerCtx: waku.brokerCtx,
|
|
)
|
|
)
|
|
|
|
proc checkApiAvailability*(self: MessagingClient): Result[void, string] =
|
|
## Shared guard for the api operation module.
|
|
if self.isNil():
|
|
return err("MessagingClient is not initialized")
|
|
|
|
return ok()
|