mirror of
https://git.asonix.dog/asonix/background-jobs.git
synced 2024-11-25 05:21:00 +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(
|
||||
mut self,
|
||||
processor: impl Processor<Job = impl Job<State = State> + Send + 'static> + Send + 'static,
|
||||
) -> Self {
|
||||
self.queues.insert(processor.queue().to_owned(), 4);
|
||||
pub fn register<P, J>(mut self, processor: P) -> Self
|
||||
where
|
||||
P: Processor<Job = J> + Send + 'static,
|
||||
J: Job<State = State>,
|
||||
{
|
||||
self.queues.insert(P::QUEUE.to_owned(), 4);
|
||||
self.processors.register_processor(processor);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -183,16 +183,6 @@ pub trait Processor: Clone {
|
|||
|
||||
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)]
|
||||
|
|
|
@ -72,12 +72,13 @@ where
|
|||
///
|
||||
/// `ProcessorMap`s are useless if no processors are registerd before workers are spawned, so
|
||||
/// make sure to register all your processors up-front.
|
||||
pub fn register_processor(
|
||||
&mut self,
|
||||
processor: impl Processor<Job = impl Job<State = S> + 'static> + Send + 'static,
|
||||
) {
|
||||
pub fn register_processor<P, J>(&mut self, processor: P)
|
||||
where
|
||||
P: Processor<Job = J> + Send + 'static,
|
||||
J: Job<State = S>,
|
||||
{
|
||||
self.inner.insert(
|
||||
processor.name().to_owned(),
|
||||
P::NAME.to_owned(),
|
||||
Box::new(move |value, state| processor.process(value, state)),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue