January 2019
Intermediate to advanced
520 pages
14h 32m
English
Everything is ready for the implementation of the main function:
fn main() -> Result<(), Error> { env_logger::init(); let (tx, rx) = channel(); let addr: SocketAddr = env::var("ADDRESS")?.parse()?; let mut server = ServerBuilder::new_plain(); server.http.set_addr(addr)?; let ring = RingImpl::new(tx); server.add_service(RingServer::new_service_def(ring)); server.http.set_cpu_pool_threads(4); let _server = server.build()?; worker_loop(rx)}
We initialized a logger and created a channel that we will use to send actions from RingImpl to a worker. We extracted SocketAddr from the ADDRESS environment variable and used this value to bind a server to the provided address.
We created a ServerBuilder instance with the new_plain method. ...
Read now
Unlock full access