logos-messaging-nim/logos_delivery/api/messaging_client_interface.nim
NagyZoltanPeter 8456245714
Structured Broker API: interface/impl split + nim-brokers integration
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
2026-06-19 08:25:25 +02:00

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.}