Skip to content

Commit 611d8e7

Browse files
committed
ref: moved delegate into own file
1 parent 3b22350 commit 611d8e7

File tree

3 files changed

+36
-34
lines changed

3 files changed

+36
-34
lines changed

src/flow_queue/delegate.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use lapin::message::{DeliveryResult};
2+
use lapin::ConsumerDelegate;
3+
use std::future::Future;
4+
use std::pin::Pin;
5+
6+
struct QueueDelegate;
7+
8+
impl ConsumerDelegate for QueueDelegate {
9+
fn on_new_delivery(
10+
&self,
11+
delivery: DeliveryResult,
12+
) -> Pin<Box<dyn Future<Output = ()> + Send>> {
13+
let optional_delivery = match delivery {
14+
Ok(option) => option,
15+
Err(error) => {
16+
todo!("error handling")
17+
}
18+
};
19+
20+
let delivery = match optional_delivery {
21+
Some(del) => del,
22+
None => {
23+
todo!("error handling")
24+
}
25+
};
26+
todo!("consumer shoud consume the data of delivy as &Vec<u8>")
27+
}
28+
29+
fn drop_prefetched_messages(&self) -> Pin<Box<dyn Future<Output = ()> + Send>> {
30+
todo!("")
31+
}
32+
}

src/flow_queue/handler.rs

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ pub async fn declare_queues(flow_channel: FlowChannel, names: Vec<QueueName>) {
3030
info!("Declared queue: {}", channel_name)
3131
}
3232
Err(error) => {
33-
let str = format!("Cannot declare queue: {}, Reason: {}", channel_name, error);
34-
error!(str);
35-
panic!(str)
33+
panic!("Cannot declare queue: {}, Reason: {}", channel_name, error);
3634
}
3735
};
3836
}
@@ -77,33 +75,4 @@ pub async fn consume_message(channel: FlowChannel, queue_protocol: QueueProtocol
7775
.unwrap();
7876

7977
consumer.set_delegate(SendQueueDelegate);
80-
}
81-
82-
struct SendQueueDelegate;
83-
84-
impl ConsumerDelegate for SendQueueDelegate {
85-
fn on_new_delivery(
86-
&self,
87-
delivery: DeliveryResult,
88-
) -> Pin<Box<dyn Future<Output = ()> + Send>> {
89-
let optional_delivery = match delivery {
90-
Ok(option) => option,
91-
Err(error) => {
92-
todo!("")
93-
}
94-
};
95-
96-
let delivery = match optional_delivery {
97-
Some(del) => del,
98-
None => {
99-
todo!("")
100-
}
101-
};
102-
103-
todo!()
104-
}
105-
106-
fn drop_prefetched_messages(&self) -> Pin<Box<dyn Future<Output = ()> + Send>> {
107-
todo!()
108-
}
109-
}
78+
}

src/flow_queue/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pub mod connection;
22
pub mod name;
3-
pub mod handler;
3+
pub mod handler;
4+
pub mod delegate;

0 commit comments

Comments
 (0)