Defining channel messages
Our runner actor needs to periodically send messages to our state actor and then send a batch of chats to a server. Considering the functionality of our runner actor, we can see that it does not need a state but does need to send messages. Before building our runner actor, we must build the messages that will be sent to actors and servers. In the src/actors/messages.rs
file, we start by importing what we need with the following code:
use serde::Serialize; use std::env;
We will be using the Serialize
trait to enable us to process the body data from HTTP requests. Now that we have imported what we need, we can define the type of messages that are being sent to actors. If we think about what we need, we will be sending messages to the state actor to either get cached data or insert data. The state actor can return data and return empty data if there are no chats cached. Considering that we have three different types of messages, we have the following enum...