Crate armature_messaging

Crate armature_messaging 

Source
Expand description

§Armature Messaging

Message broker integrations for the Armature framework.

This crate provides a unified interface for working with various message brokers:

  • RabbitMQ - AMQP message broker
  • Kafka - Distributed event streaming
  • NATS - Cloud-native messaging
  • AWS SQS/SNS - AWS messaging services

§Features

Enable specific backends via Cargo features:

  • rabbitmq - RabbitMQ/AMQP support
  • kafka - Apache Kafka support
  • nats - NATS support
  • aws - AWS SQS/SNS support
  • full - All backends

§Example

use armature_messaging::{Message, MessageBroker, MessageHandler};

// Define a message handler
struct MyHandler;

#[async_trait::async_trait]
impl MessageHandler for MyHandler {
    async fn handle(&self, message: Message) -> Result<(), MessagingError> {
        println!("Received: {:?}", message.payload);
        Ok(())
    }
}

// Connect and subscribe
#[cfg(feature = "rabbitmq")]
async fn example() -> Result<(), MessagingError> {
    let broker = RabbitMqBroker::connect("amqp://localhost:5672").await?;
    broker.subscribe("my-queue", MyHandler).await?;
    Ok(())
}

Re-exports§

pub use config::*;
pub use error::*;

Modules§

aws
AWS SQS/SNS message broker implementation
config
Configuration types for messaging backends
error
Error types for messaging operations
kafka
Apache Kafka message broker implementation
nats
NATS message broker implementation
rabbitmq
RabbitMQ message broker implementation

Structs§

FnHandler
Function-based message handler
Message
A message to be sent or received from a message broker
MessagingBuilder
Builder for creating message broker connections
PublishOptions
Options for publishing a message
SubscribeOptions
Options for subscribing to messages

Enums§

AckMode
Acknowledgment behavior for received messages
ProcessingResult
Result of processing a message

Traits§

MessageBroker
Core trait for message brokers
MessageHandler
Trait for handling received messages
Subscription
Subscription handle for managing a subscription