Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved docs #21

Merged
merged 5 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chorus_book/src/guide-choreography.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl Choreography for HelloWorldChoreography {

`Choreography` must implement the `run` method which defines the behavior of the system. The `run` method takes a reference to an object that implements the `ChoreoOp` trait. The `ChoreoOp` trait provides choreographic operators such as `locally` and `comm`.

Also, each `Choreography` has an associated type `L`, called it's location set; this is the set of `ChoreographyLocation`s that the `Choreography` can operate on. To build a location set, you can use the macro `LocationSet!`.
Also, each `Choreography` has an associated `LocationSet` type, `L`; this is the `LocationSet` that the `Choreography` can operate on.

## Choreographic Operators

Expand Down
17 changes: 17 additions & 0 deletions chorus_book/src/guide-locations.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,20 @@ The `ChoreographyLocation` trait provides the `name` method, which returns the n
let name = Alice::name();
assert_eq!(name, "Alice");
```

## Location Set

A `LocationSet` is a special type representing a set of `ChoreographyLocation` types. It's used to ensure type safety within the system, and you'll see its application in future sections. To build a `LocationSet` type, you can use the `LocationSet` macro from the `chorus_lib` crate.

```rust
# extern crate chorus_lib;
# use chorus_lib::core::ChoreographyLocation;
# #[derive(ChoreographyLocation)]
# struct Alice;
#
# #[derive(ChoreographyLocation)]
# struct Bob;
use chorus_lib::core::LocationSet;

type L = LocationSet!(Alice, Bob);
```
2 changes: 1 addition & 1 deletion chorus_book/src/guide-transport.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ In the above example, the transport will start the HTTP server on port 8080 on l

## Creating a Custom Transport

You can also create your own transport by implementing the `Transport` trait. It might be helpful first build a `TransportConfig` to have the the information that you need for each `ChoreographyLocation`, and then have a constructor that takes the `TransportConfig` and builds the `Transport` based on it. While the syntax is similar to `HttpTransportConfig`, the type of information for each `ChoreographyLocation` might diverge from the `(host_name, port)` format presented here. In some cases, the `target_information` could even have a different type than the following `other_location_information` types. But all the `other_location_information`s should have the same type.
You can also create your own transport by implementing the `Transport` trait. It might be helpful to first build a `TransportConfig` to have the the information that you need for each `ChoreographyLocation`, and then have a constructor that takes the `TransportConfig` and builds the `Transport` based on it. While the syntax is similar to `HttpTransportConfig`, which is `HttpTransportConfigBuilder::for_target(target_location, target_information)`, chained with information about other locations using the `.with(other_location, other_location_information)`, the type of information for each `ChoreographyLocation` might diverge from the `(host_name, port)` format presented in `HttpTransport`. In some cases, the `target_information` could even have a different type than the following `other_location_information` types. But all the `other_location_information`s should have the same type.

```rust
{{#include ./header.txt}}
Expand Down