Skip to content

Commit

Permalink
feat: add tag field to PublishedMessage (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakowskiii authored Jun 14, 2023
1 parent 79f37fd commit ebe8582
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion relay_client/src/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use {
self::connection::{connection_event_loop, ConnectionControl},
crate::{error::Error, ConnectionOptions},
relay_rpc::{
domain::{SubscriptionId, Topic},
domain::{MessageId, SubscriptionId, Topic},
rpc::{
BatchFetchMessages,
BatchReceiveMessages,
Expand Down Expand Up @@ -74,8 +74,10 @@ mod stream;
/// The message received from a subscription.
#[derive(Debug)]
pub struct PublishedMessage {
pub id: MessageId,
pub topic: Topic,
pub message: Arc<str>,
pub tag: u32,
pub published_at: chrono::DateTime<chrono::Utc>,
pub received_at: chrono::DateTime<chrono::Utc>,
}
Expand All @@ -86,8 +88,10 @@ impl PublishedMessage {
let now = chrono::Utc::now();

Self {
id: request.id(),
topic: data.topic.clone(),
message: data.message.clone(),
tag: data.tag,
// TODO: Set proper value once implemented.
published_at: now,
received_at: now,
Expand Down
4 changes: 4 additions & 0 deletions relay_client/src/websocket/inbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ where
&self.data
}

pub fn id(&self) -> MessageId {
self.id
}

/// Sends the response back to the Relay. The value is a
/// `Result<T::Response, T::Error>` (see [`RequestPayload`] trait for
/// details).
Expand Down

0 comments on commit ebe8582

Please sign in to comment.