Skip to content

Commit

Permalink
Merge pull request #21 from lsd-ucsc/improved-doc
Browse files Browse the repository at this point in the history
Improved docs
  • Loading branch information
shumbo authored Oct 6, 2023
2 parents 68ca499 + 2ba79a3 commit c2f4ebb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
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

0 comments on commit c2f4ebb

Please sign in to comment.