mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-06-26 11:29:28 +00:00
Squash of the initial structured-API POC work (1d684bf8..c37dcf84): - WIP: structured Broker API interface + impl (Logos Delivery facade) - Restructured folders; interfaces under logos_delivery/api; MessagingClient and ReliableChannelManager reworked as BrokerInterface/BrokerImplement - API types elevated under logos_delivery/api/types.nim - onelogosdelivery target; wakunode2 / FFI lib build fixes - nim-brokers integration + version bumps; git_version into FFI lib version - compile fixes for tests
49 lines
1.6 KiB
Nim
49 lines
1.6 KiB
Nim
## MessagingClientInterface — the messaging API (waku/api) minus createNode.
|
|
##
|
|
## Node creation lives in the facade (LogosDeliveryInterface); this interface exposes
|
|
## subscribe / unsubscribe / send only.
|
|
|
|
import results, chronos
|
|
import brokers/broker_interface
|
|
|
|
import logos_delivery/api/types
|
|
export types
|
|
|
|
BrokerInterface(API, MessagingClientInterface):
|
|
EventBroker:
|
|
# Event emitted when a message is sent to the network
|
|
type MessageSentEvent* = object
|
|
requestId*: RequestId
|
|
messageHash*: string
|
|
|
|
EventBroker:
|
|
# Event emitted when a message send operation fails
|
|
type MessageErrorEvent* = object
|
|
requestId*: RequestId
|
|
messageHash*: string
|
|
error*: string
|
|
|
|
EventBroker:
|
|
# Confirmation that a message has been correctly delivered to some neighbouring nodes.
|
|
type MessagePropagatedEvent* = object
|
|
requestId*: RequestId
|
|
messageHash*: string
|
|
|
|
EventBroker:
|
|
# Event emitted when a message is received via Waku
|
|
type MessageReceivedEvent* = object
|
|
messageHash*: string
|
|
message*: WakuMessage
|
|
|
|
RequestBroker:
|
|
proc subscribe(contentTopic: ContentTopic): Future[Result[void, string]] {.async.}
|
|
|
|
RequestBroker:
|
|
proc unsubscribe(contentTopic: ContentTopic): Future[Result[void, string]] {.async.}
|
|
|
|
RequestBroker:
|
|
# Returns the RequestId in its string form. Named `sendMessage` (not `send`)
|
|
# because broker request verbs must be globally unique across all interfaces
|
|
# in the library, and ReliableChannelManagerInterface also has a send.
|
|
proc send(envelope: MessageEnvelope): Future[Result[RequestId, string]] {.async.}
|