January 2019
Intermediate to advanced
520 pages
14h 32m
English
To interact with other microservice instances and to call their remote methods, we will create a separate struct, because it's more convenient than using the JSON-RPC Cilent directly. But in any case, we use this type internally in our struct:
struct Remote { client: Client,}
We will use the Remote struct to make calls to remote services. To create the struct, we will use the following constructor:
impl Remote { fn new(addr: SocketAddr) -> Self { let url = format!("http://{}", addr); let client = Client::new(url, None, None); Self { client } }}
The Client struct expects the String URL as a parameter, but we will use SocketAddr to create a URL.
Also, we need a generic function that will use the Client instance to call remote methods. ...
Read now
Unlock full access