Skip to content

Commit d608335

Browse files
committed
refactor(dmq): rename 'DmqConsumerPallas' to 'DmqConsumerClientPallas'
1 parent 00e2775 commit d608335

File tree

6 files changed

+26
-25
lines changed

6 files changed

+26
-25
lines changed

internal/mithril-dmq/src/consumer/client/interface.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use std::fmt::Debug;
22

33
use mithril_common::{StdResult, crypto_helper::TryFromBytes, entities::PartyId};
44

5-
/// Trait for consuming messages from a DMQ node.
5+
/// Trait for the client side of consuming messages from a DMQ node.
66
#[cfg_attr(test, mockall::automock)]
77
#[async_trait::async_trait]
8-
pub trait DmqConsumer<M: TryFromBytes + Debug + Send + Sync>: Send + Sync {
8+
pub trait DmqConsumerClient<M: TryFromBytes + Debug + Send + Sync>: Send + Sync {
99
/// Consume messages from the DMQ node.
1010
async fn consume_messages(&self) -> StdResult<Vec<(M, PartyId)>>;
1111
}

internal/mithril-dmq/src/consumer/client/pallas.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ use mithril_common::{
1212
logging::LoggerExtensions,
1313
};
1414

15-
use crate::DmqConsumer;
15+
use crate::DmqConsumerClient;
1616

17-
/// A DMQ consumer implementation.
17+
/// A DMQ client consumer implementation.
1818
///
1919
/// This implementation is built upon the n2c mini-protocols DMQ implementation in Pallas.
20-
pub struct DmqConsumerPallas<M: TryFromBytes + Debug> {
20+
pub struct DmqConsumerClientPallas<M: TryFromBytes + Debug> {
2121
socket: PathBuf,
2222
network: CardanoNetwork,
2323
client: Mutex<Option<DmqClient>>,
2424
logger: Logger,
2525
phantom: PhantomData<M>,
2626
}
2727

28-
impl<M: TryFromBytes + Debug> DmqConsumerPallas<M> {
29-
/// Creates a new `DmqConsumerPallas` instance.
28+
impl<M: TryFromBytes + Debug> DmqConsumerClientPallas<M> {
29+
/// Creates a new `DmqConsumerClientPallas` instance.
3030
pub fn new(socket: PathBuf, network: CardanoNetwork, logger: Logger) -> Self {
3131
Self {
3232
socket,
@@ -47,7 +47,7 @@ impl<M: TryFromBytes + Debug> DmqConsumerPallas<M> {
4747
);
4848
DmqClient::connect(&self.socket, self.network.code())
4949
.await
50-
.with_context(|| "DmqConsumerPallas failed to create a new client")
50+
.with_context(|| "DmqConsumerClientPallas failed to create a new client")
5151
}
5252

5353
/// Gets the cached `DmqClient`, creating a new one if it does not exist.
@@ -128,7 +128,7 @@ impl<M: TryFromBytes + Debug> DmqConsumerPallas<M> {
128128
}
129129

130130
#[async_trait::async_trait]
131-
impl<M: TryFromBytes + Debug + Sync + Send> DmqConsumer<M> for DmqConsumerPallas<M> {
131+
impl<M: TryFromBytes + Debug + Sync + Send> DmqConsumerClient<M> for DmqConsumerClientPallas<M> {
132132
async fn consume_messages(&self) -> StdResult<Vec<(M, PartyId)>> {
133133
let messages = self.consume_messages_internal().await;
134134
if messages.is_err() {
@@ -247,7 +247,7 @@ mod tests {
247247
let reply_messages = fake_msgs();
248248
let server = setup_dmq_server(socket_path.clone(), reply_messages);
249249
let client = tokio::spawn(async move {
250-
let consumer = DmqConsumerPallas::new(
250+
let consumer = DmqConsumerClientPallas::new(
251251
socket_path,
252252
CardanoNetwork::TestNet(0),
253253
TestLogger::stdout(),
@@ -280,7 +280,7 @@ mod tests {
280280
let reply_messages = vec![];
281281
let server = setup_dmq_server(socket_path.clone(), reply_messages);
282282
let client = tokio::spawn(async move {
283-
let consumer = DmqConsumerPallas::<DmqMessageTestPayload>::new(
283+
let consumer = DmqConsumerClientPallas::<DmqMessageTestPayload>::new(
284284
socket_path,
285285
CardanoNetwork::TestNet(0),
286286
TestLogger::stdout(),
@@ -304,7 +304,7 @@ mod tests {
304304
let reply_messages = fake_msgs();
305305
let server = setup_dmq_server(socket_path.clone(), reply_messages);
306306
let client = tokio::spawn(async move {
307-
let consumer = DmqConsumerPallas::<DmqMessageTestPayload>::new(
307+
let consumer = DmqConsumerClientPallas::<DmqMessageTestPayload>::new(
308308
socket_path,
309309
CardanoNetwork::TestNet(0),
310310
TestLogger::stdout(),

internal/mithril-dmq/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod message;
66
mod publisher;
77
pub mod test;
88

9-
pub use consumer::{DmqConsumer, DmqConsumerPallas};
9+
pub use consumer::{DmqConsumerClient, DmqConsumerClientPallas};
1010
pub use message::DmqMessageBuilder;
1111
pub use publisher::{DmqPublisher, DmqPublisherPallas};
1212

internal/mithril-dmq/src/test/double/consumer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ use tokio::sync::Mutex;
44

55
use mithril_common::{StdResult, crypto_helper::TryFromBytes, entities::PartyId};
66

7-
use crate::DmqConsumer;
7+
use crate::DmqConsumerClient;
88

99
type ConsumerReturn<M> = StdResult<Vec<(M, PartyId)>>;
1010

11-
/// A fake implementation of the [DmqConsumer] trait for testing purposes.
11+
/// A fake implementation of the [DmqConsumerClient] trait for testing purposes.
1212
pub struct DmqConsumerFake<M: TryFromBytes + Debug + Send + Sync> {
1313
results: Mutex<VecDeque<ConsumerReturn<M>>>,
1414
}
@@ -23,7 +23,7 @@ impl<M: TryFromBytes + Debug + Send + Sync> DmqConsumerFake<M> {
2323
}
2424

2525
#[async_trait::async_trait]
26-
impl<M: TryFromBytes + Debug + Send + Sync> DmqConsumer<M> for DmqConsumerFake<M> {
26+
impl<M: TryFromBytes + Debug + Send + Sync> DmqConsumerClient<M> for DmqConsumerFake<M> {
2727
async fn consume_messages(&self) -> ConsumerReturn<M> {
2828
let mut results = self.results.lock().await;
2929

mithril-aggregator/src/dependency_injection/builder/enablers/misc.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::time::Duration;
1212
#[cfg(feature = "future_dmq")]
1313
use mithril_common::messages::RegisterSignatureMessageDmq;
1414
#[cfg(feature = "future_dmq")]
15-
use mithril_dmq::DmqConsumerPallas;
15+
use mithril_dmq::DmqConsumerClientPallas;
1616
use mithril_signed_entity_lock::SignedEntityTypeLock;
1717

1818
use crate::database::repository::CertificateRepository;
@@ -89,11 +89,12 @@ impl DependenciesBuilder {
8989
#[cfg(feature = "future_dmq")]
9090
let signature_consumer = match self.configuration.dmq_node_socket_path() {
9191
Some(dmq_node_socket_path) => {
92-
let dmq_consumer = Arc::new(DmqConsumerPallas::<RegisterSignatureMessageDmq>::new(
93-
dmq_node_socket_path,
94-
self.configuration.get_network()?,
95-
self.root_logger(),
96-
));
92+
let dmq_consumer =
93+
Arc::new(DmqConsumerClientPallas::<RegisterSignatureMessageDmq>::new(
94+
dmq_node_socket_path,
95+
self.configuration.get_network()?,
96+
self.root_logger(),
97+
));
9798
Arc::new(SignatureConsumerDmq::new(dmq_consumer)) as Arc<dyn SignatureConsumer>
9899
}
99100
_ => Arc::new(SignatureConsumerNoop) as Arc<dyn SignatureConsumer>,

mithril-aggregator/src/services/signature_consumer/dmq.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ use mithril_common::{
99
messages::RegisterSignatureMessageDmq,
1010
};
1111

12-
use mithril_dmq::DmqConsumer;
12+
use mithril_dmq::DmqConsumerClient;
1313

1414
use super::SignatureConsumer;
1515

1616
/// DMQ implementation of the [SignatureConsumer] trait.
1717
pub struct SignatureConsumerDmq {
18-
dmq_consumer: Arc<dyn DmqConsumer<RegisterSignatureMessageDmq>>,
18+
dmq_consumer: Arc<dyn DmqConsumerClient<RegisterSignatureMessageDmq>>,
1919
}
2020

2121
impl SignatureConsumerDmq {
2222
/// Creates a new instance of [SignatureConsumerDmq].
23-
pub fn new(dmq_consumer: Arc<dyn DmqConsumer<RegisterSignatureMessageDmq>>) -> Self {
23+
pub fn new(dmq_consumer: Arc<dyn DmqConsumerClient<RegisterSignatureMessageDmq>>) -> Self {
2424
Self { dmq_consumer }
2525
}
2626
}

0 commit comments

Comments
 (0)