January 2019
Intermediate to advanced
520 pages
14h 32m
English
We need to create an empty struct, because our worker doesn't have a state and will only transform incoming messages:
struct WokerHandler {}
We use the WorkerHandler struct as the handler for the queue and use it with QueueActor later. Implement the QueueHandler trait, which is required by QueueActor:
impl QueueHandler for WokerHandler { type Incoming = QrRequest; type Outgoing = QrResponse; fn incoming(&self) -> &str { REQUESTS } fn outgoing(&self) -> &str { RESPONSES } fn handle( &self, _: &TaskId, incoming: Self::Incoming, ) -> Result<Option<Self::Outgoing>, Error> { debug!("In: {:?}", incoming); let outgoing = self.scan(&incoming.image).into(); debug!("Out: {:?}", outgoing); Ok(Some(outgoing)) }}
Since this handler takes requests ...
Read now
Unlock full access