forked from the-distro/ofborg
move prefetch qos to WorkerChannel
This way the log collecter can use a channel with prefetching while the other workers still consume items one by one.
This commit is contained in:
parent
51b4c3dbc9
commit
f652901df2
|
@ -56,7 +56,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
no_wait: false,
|
no_wait: false,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let handle = chan.consume(
|
let handle = easylapin::WorkerChannel(chan).consume(
|
||||||
tasks::evaluationfilter::EvaluationFilterWorker::new(cfg.acl()),
|
tasks::evaluationfilter::EvaluationFilterWorker::new(cfg.acl()),
|
||||||
easyamqp::ConsumeConfig {
|
easyamqp::ConsumeConfig {
|
||||||
queue: queue_name.clone(),
|
queue: queue_name.clone(),
|
||||||
|
|
|
@ -57,7 +57,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
no_wait: false,
|
no_wait: false,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let handle = chan.consume(
|
let handle = easylapin::WorkerChannel(chan).consume(
|
||||||
tasks::githubcommentfilter::GitHubCommentWorker::new(cfg.acl(), cfg.github()),
|
tasks::githubcommentfilter::GitHubCommentWorker::new(cfg.acl(), cfg.github()),
|
||||||
easyamqp::ConsumeConfig {
|
easyamqp::ConsumeConfig {
|
||||||
queue: "build-inputs".to_owned(),
|
queue: "build-inputs".to_owned(),
|
||||||
|
|
|
@ -46,7 +46,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
no_wait: false,
|
no_wait: false,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let handle = chan.consume(
|
let handle = easylapin::WorkerChannel(chan).consume(
|
||||||
tasks::githubcommentposter::GitHubCommentPoster::new(cfg.github_app_vendingmachine()),
|
tasks::githubcommentposter::GitHubCommentPoster::new(cfg.github_app_vendingmachine()),
|
||||||
easyamqp::ConsumeConfig {
|
easyamqp::ConsumeConfig {
|
||||||
queue: "build-results".to_owned(),
|
queue: "build-results".to_owned(),
|
||||||
|
|
|
@ -48,6 +48,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
no_wait: false,
|
no_wait: false,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
// Regular channel, we want prefetching here.
|
||||||
let handle = chan.consume(
|
let handle = chan.consume(
|
||||||
tasks::log_message_collector::LogMessageCollector::new(
|
tasks::log_message_collector::LogMessageCollector::new(
|
||||||
PathBuf::from(cfg.log_storage.clone().unwrap().path),
|
PathBuf::from(cfg.log_storage.clone().unwrap().path),
|
||||||
|
|
|
@ -53,7 +53,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
no_wait: false,
|
no_wait: false,
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let handle = chan.consume(
|
let handle = easylapin::WorkerChannel(chan).consume(
|
||||||
tasks::evaluate::EvaluationWorker::new(
|
tasks::evaluate::EvaluationWorker::new(
|
||||||
cloner,
|
cloner,
|
||||||
&nix,
|
&nix,
|
||||||
|
|
|
@ -86,8 +86,6 @@ impl<'a, W: SimpleWorker + 'a> ConsumerExt<'a, W> for CloseOnDrop<Channel> {
|
||||||
type Handle = Pin<Box<dyn Future<Output = ()> + 'a>>;
|
type Handle = Pin<Box<dyn Future<Output = ()> + 'a>>;
|
||||||
|
|
||||||
fn consume(self, mut worker: W, config: ConsumeConfig) -> Result<Self::Handle, Self::Error> {
|
fn consume(self, mut worker: W, config: ConsumeConfig) -> Result<Self::Handle, Self::Error> {
|
||||||
task::block_on(self.basic_qos(1, BasicQosOptions::default()))?;
|
|
||||||
|
|
||||||
let mut consumer = task::block_on(self.basic_consume(
|
let mut consumer = task::block_on(self.basic_consume(
|
||||||
&config.queue,
|
&config.queue,
|
||||||
&config.consumer_tag,
|
&config.consumer_tag,
|
||||||
|
@ -117,6 +115,20 @@ impl<'a, W: SimpleWorker + 'a> ConsumerExt<'a, W> for CloseOnDrop<Channel> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Same as a regular channel, but without prefetching,
|
||||||
|
// used for services with multiple instances.
|
||||||
|
pub struct WorkerChannel(pub CloseOnDrop<Channel>);
|
||||||
|
|
||||||
|
impl<'a, W: SimpleWorker + 'a> ConsumerExt<'a, W> for WorkerChannel {
|
||||||
|
type Error = lapin::Error;
|
||||||
|
type Handle = Pin<Box<dyn Future<Output = ()> + 'a>>;
|
||||||
|
|
||||||
|
fn consume(self, worker: W, config: ConsumeConfig) -> Result<Self::Handle, Self::Error> {
|
||||||
|
task::block_on(self.0.basic_qos(1, BasicQosOptions::default()))?;
|
||||||
|
self.0.consume(worker, config)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct ChannelNotificationReceiver<'a> {
|
struct ChannelNotificationReceiver<'a> {
|
||||||
channel: &'a mut CloseOnDrop<lapin::Channel>,
|
channel: &'a mut CloseOnDrop<lapin::Channel>,
|
||||||
deliver: &'a Delivery,
|
deliver: &'a Delivery,
|
||||||
|
|
Loading…
Reference in a new issue