January 2019
Intermediate to advanced
520 pages
14h 32m
English
Import all necessary types for a server. It's worth noting only those with which you're unfamiliar:
use actix::{Actor, Addr};use actix::sync::SyncArbiter;
Addr is an address of an actor. SyncArbiter is a synchronous event-loop controller that handles every message synchronously. We need it for resizing actors. Also, add the actors module and import all the types we declared in the submodules:
mod actors;use self::actors::{ count::{Count, CountActor}, log::{Log, LogActor}, resize::{Resize, ResizeActor},};
We need a shared state to keep all the addresses of the actors that we'll use to handle requests:
#[derive(Clone)]struct State { resize: Addr<ResizeActor>, count: Addr<CountActor>, log: Addr<LogActor>,}
The
Read now
Unlock full access