From 31eaf1aca54e9a60b0a00599084d9b54b173e2b7 Mon Sep 17 00:00:00 2001 From: Soroush Zare Date: Thu, 21 Sep 2023 16:30:29 -0700 Subject: [PATCH] Update the guide for Transport --- chorus_book/src/guide-transport.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/chorus_book/src/guide-transport.md b/chorus_book/src/guide-transport.md index 67315e2..f4f00e8 100644 --- a/chorus_book/src/guide-transport.md +++ b/chorus_book/src/guide-transport.md @@ -24,6 +24,8 @@ let transport_channel = LocalTransportChannel::::new() ``` To use the `local` transport, first import the `LocalTransport` struct from the `chorus_lib` crate. + +Then build the transport by using the `LocalTransport::new` associated function, which takes a target location (explained in the [Projector section](./guide-projector.md)) and the `LocalTransportChannel`. ```rust # extern crate chorus_lib; @@ -38,10 +40,6 @@ use chorus_lib::transport::local::{LocalTransport}; let alice_transport = LocalTransport::new(Alice, transport_channel.clone()); ``` - Then build the transport by using the `LocalTransport::new` associated function, which takes a target location (explained in the [Projector section](./guide-projector.md)) and the `LocalTransportChannel`. - -You can construct a `LocalTransport` instance by passing a target location(lained in the [Projector section](./guide-projector.md)) and a `LocalTransportChannel`. - Because of the nature of the `Local` transport, you must use the same `LocalTransportChannel` instance for all locations. You can `clone` the `LocalTransprotChannel` instance and pass it to each `Projector::new` constructor. ```rust @@ -91,7 +89,7 @@ To use the `http` transport, import the `HttpTransport` struct and the `HttpTran use chorus_lib::transport::http::{HttpTransport, HttpTransportConfig}; ``` -The new constructor takes a "configuration" of type `HttpTransportConfig`. To build the config, you should use the pattern `HttpTransportConfig::for_target(target_location, target_information).with(other_location, other_location_information)...build()` where the target_location is the target ChoreographyLocation and target_information is the required information for the target, and each following `.with(other_location, other_location_information)` is a ChoreographyLocation and the required information for it (`(host_name, port)` in this case). For HttpTransport You can think of TransportConfig as a map from locations to the hostname and port of the location. But for a generic Transport, it can contain any kind of information. +The primary constructor requires an argument of type `HttpTransportConfig`. To create an instance of this configuration, utilize the builder pattern. Start with `HttpTransportConfig::for_target(target_location, target_information)` and then chain additional locations using the `.with(other_location, other_location_information)` method. Conclude with `.build()`. In this context, `target_location` refers to the primary `ChoreographyLocation` and `target_information` encapsulates essential details for that location, typically a tuple of `(host_name, port)`. Subsequent calls to `.with()` allow you to add more locations and their respective information. For the `HttpTransport`, think of `TransportConfig` as a mapping from locations to their hostnames and ports. However, for generic Transports, it can hold diverse types of information. ```rust {{#include ./header.txt}}