mirror of
https://git.asonix.dog/asonix/background-jobs.git
synced 2025-02-17 22:05:15 +00:00
Remove unneeded trait methods
This commit is contained in:
parent
89eb549c44
commit
267ffa81b0
3 changed files with 12 additions and 20 deletions
|
@ -93,11 +93,12 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn register(
|
pub fn register<P, J>(mut self, processor: P) -> Self
|
||||||
mut self,
|
where
|
||||||
processor: impl Processor<Job = impl Job<State = State> + Send + 'static> + Send + 'static,
|
P: Processor<Job = J> + Send + 'static,
|
||||||
) -> Self {
|
J: Job<State = State>,
|
||||||
self.queues.insert(processor.queue().to_owned(), 4);
|
{
|
||||||
|
self.queues.insert(P::QUEUE.to_owned(), 4);
|
||||||
self.processors.register_processor(processor);
|
self.processors.register_processor(processor);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,16 +183,6 @@ pub trait Processor: Clone {
|
||||||
|
|
||||||
Box::new(fut)
|
Box::new(fut)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Hack to access Associated Constant from impl type
|
|
||||||
fn name(&self) -> &'static str {
|
|
||||||
Self::NAME
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Hack to access Associated Constant from impl type
|
|
||||||
fn queue(&self) -> &'static str {
|
|
||||||
Self::QUEUE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Fail)]
|
#[derive(Clone, Debug, Fail)]
|
||||||
|
|
|
@ -72,12 +72,13 @@ where
|
||||||
///
|
///
|
||||||
/// `ProcessorMap`s are useless if no processors are registerd before workers are spawned, so
|
/// `ProcessorMap`s are useless if no processors are registerd before workers are spawned, so
|
||||||
/// make sure to register all your processors up-front.
|
/// make sure to register all your processors up-front.
|
||||||
pub fn register_processor(
|
pub fn register_processor<P, J>(&mut self, processor: P)
|
||||||
&mut self,
|
where
|
||||||
processor: impl Processor<Job = impl Job<State = S> + 'static> + Send + 'static,
|
P: Processor<Job = J> + Send + 'static,
|
||||||
) {
|
J: Job<State = S>,
|
||||||
|
{
|
||||||
self.inner.insert(
|
self.inner.insert(
|
||||||
processor.name().to_owned(),
|
P::NAME.to_owned(),
|
||||||
Box::new(move |value, state| processor.process(value, state)),
|
Box::new(move |value, state| processor.process(value, state)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue