Implementing actors

First, we have to import all necessary dependencies. We'll use the same common dependencies from previous examples in this chapter, but you also have to add the following dependencies to Cargo.toml:

actix = "0.7"
failure = "0.1"
syslog = "4.0"

We added the actix crate. It's the main crate for the current example. Also, we imported the failure crate, because we'll use the Fail trait to get access to the compat method, which converts any error type that implements the Fail trait into a Compat type that implements the std::error::Error trait.

Also, we'll use syslog and we added the syslog crate to access the system API. syslog is a standard of system logging. We'll use it to demonstrate how actors can perform separate tasks of the whole process. Now we can add the actors module to our example and add three actors.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.107.193