Building our runner actor
Our runner actor consistently loops, sending messages to the state actor, asking for batched data, and sending the batched data to the server if the batched data is present. This means that our actor will be sending and receiving messages throughout the lifetime of the program. With the behavior of the runner actor in mind, it should not be a shock that we need the following imports in the src/actors/runner.rs
file:
use super::messages::{MessageType, StateActorMessage}; use tokio::sync::mpsc::{Sender, Receiver}; use std::time;
We have imported the messages and the modules required to sleep for a period of seconds. We have also used type aliases to define the type of channels our runner actor will be supporting. We can now define the runner actor with the following code:
pub struct RunnerActor { pub interval: i32, pub receiver: Receiver<StateActorMessage>, pub sender: Sender...