Skip to main content

publish_messages

Function publish_messages 

Source
pub async fn publish_messages(
    rx: UnboundedReceiver<BusMessage>,
    trader_id: TraderId,
    instance_id: UUID4,
    config: MessageBusConfig,
    backing: RedisMessageBusConfig,
) -> Result<()>
Expand description

Publishes messages received on rx to Redis streams for the given trader_id and instance_id, using config.

Buffered messages are written in batches of at most 1,000 per MULTI/EXEC, and each batch is only removed once its EXEC is acknowledged. On a retryable write error the task keeps receiving, waits out the stream reader’s backoff, and retries the same messages on a fresh connection, so a batch whose reply was lost can be written twice.

§Errors

Returns an error if:

  • The backing configuration is missing in config.
  • Establishing the initial Redis connection fails.
  • A Redis write fails with a non-retryable error.
  • The buffered messages cannot be written when the task closes.