iconoclast 0.3.1

Reusable code for Rust-based business μServices
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::error::Error;

/// A kafka message handler.
///
/// Gets passed decoded Kafka Messages of type `Self::Message`
///
/// Returns an application error `AE` if processing fails
pub trait MessageHandler<AE: Error + Send + Sync> {
    /// The type of messages this handler handles.
    ///
    /// This is typically an enum, where each variant is a message for a topic.
    type Message;

    /// topics this MessageHandler handles, topics to subscribe to
    fn topics() -> &'static [&'static str];

    fn handle(&self, kafka_message: Self::Message) -> impl Future<Output = Result<(), AE>>;
}