Server implementation

Add the src/server.rs source file and add generated modules to it:

mod ring;
mod ring_grpc;

We need these modules because we will implement the Ring trait for our RPC handler. Look at the types we will use:

use crate::ring::Empty;
use crate::ring_grpc::{Ring, RingServer};
use failure::Error;
use grpc::{Error as GrpcError, ServerBuilder, SingleResponse, RequestOptions};
use grpc_ring::Remote;
use log::{debug, trace};
use std::env;
use std::net::SocketAddr;
use std::sync::Mutex;
use std::sync::mpsc::{channel, Receiver, Sender};

The types you are not familiar with yet are ServerBuilder, which is used to create a server instance and fill it with service implementations, and SingleResponse is the result of handler calls. The other types you already know.

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

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