You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-9Lines changed: 17 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,17 +84,17 @@ def deps do
84
84
end
85
85
```
86
86
87
-
Note that this is *experimental software* and stuff *will* break. Please don’t rely on this for anything production-grade. Not yet at least.
87
+
Note that this is *experimental software* and stuff *will* break. Please don't rely on this for anything production-grade. Not yet at least.
88
88
89
89
90
90
## What is a choreography?
91
91
92
-
A choreography is a birds-eye view of an interaction between nodes in a distributed system. You have some set of *actors/—in Elixir parlance processes—that exchange /messages* while also running some /local computation/—i.e. functions that don’t rely on talking to other nodes in the system.
92
+
A choreography is a birds-eye view of an interaction between nodes in a distributed system. You have some set of *actors/—in Elixir parlance processes—that exchange /messages* while also running some /local computation/—i.e. functions that don't rely on talking to other nodes in the system.
93
93
94
94
95
95
### Choreography syntax
96
96
97
-
Chorex introduces some new syntax for choreographies. Here’s a breakdown of how it works:
97
+
Chorex introduces some new syntax for choreographies. Here's a breakdown of how it works:
98
98
99
99
```elixir
100
100
defchor [Actor1, Actor2, ...] do
@@ -194,7 +194,7 @@ defmodule Bookstore do
194
194
end
195
195
```
196
196
197
-
You will need to make a module for every actor you specify at the beginning of `defchor` and mark which actor you’re implementing like so:
197
+
You will need to make a module for every actor you specify at the beginning of `defchor` and mark which actor you're implementing like so:
198
198
199
199
```elixir
200
200
defmoduleMyFirstActordo
@@ -210,7 +210,7 @@ defmodule MySecondActor do
210
210
end
211
211
```
212
212
213
-
These modules will need to implement all of the local functions specified in the choreography. Chorex will use Elixir’s behaviour mechanism to warn you if you don’t implement every function needed. In the above example, the `MySecondActor` implements the role of `Actor2` in the choreography, and therefore needs to implement the `some_computation` function.
213
+
These modules will need to implement all of the local functions specified in the choreography. Chorex will use Elixir's behaviour mechanism to warn you if you don't implement every function needed. In the above example, the `MySecondActor` implements the role of `Actor2` in the choreography, and therefore needs to implement the `some_computation` function.
214
214
215
215
**Note:***Actor names do not need to be the same as the modules implementing them!* It is *useful* to do that, but there exist instances where you might want to write one choreography and implement it in different ways.
216
216
@@ -236,14 +236,22 @@ receive do
236
236
end
237
237
```
238
238
239
+
## Shared-state choreographies
240
+
241
+
Sometimes you might have a choreography where one or more actors need to share some state between different instantiations of the choreography. Returning to our bookseller example, the bookseller might need to keep track of a finite stock of books and ensure that no book gets double-sold.
242
+
243
+
Chorex can let you share state between different instances of the bookseller actor through a proxy. Details are under the `Chorex` module.
239
244
240
245
## Using a choreography with the rest of your project
241
246
242
-
The local functions are free to call any other code you have—they’re just normal Elixir. If that code sends and receives messages not managed by the choreography library, there is no guarantee that this will be deadlock-free.
247
+
The local functions are free to call any other code you have—they're just normal Elixir. If that code sends and receives messages not managed by the choreography library, there is no guarantee that this will be deadlock-free.
243
248
244
249
245
250
# Development
246
251
252
+
Chorex is under active development and things will change and break rapidly.
253
+
254
+
If you find any bugs or would like to suggest a feature, please [open an issue on GitHub](https://github.com/utahplt/chorex/issues).
247
255
248
256
## Changelog
249
257
@@ -263,9 +271,9 @@ We will collect change descriptions here until we come up with a more stable for
263
271
The `defchor` macro is implemented in the `Chorex` module.
264
272
265
273
- The `defchor` macro gathers a list of actors.
266
-
- For each actor, call `project` on the body of the choreography. The `project` function keeps track of the current actor as the “label” variable. (This vernacular borrowed from the academic literature.)
274
+
- For each actor, call `project` on the body of the choreography. The `project` function keeps track of the current actor as the `label` variable. (This vernacular borrowed from the academic literature.)
267
275
- The functions `project` and `project_sequence` are mutually recursive: `project_sequence` gets invoked whenever `project` encounters a block with multiple instructions.
268
-
- The `project` function walks the AST, it gathers a list of functions that will need to be implemented by each actor’s implementing module, as well as a list of top-level functions for each projection.
276
+
- The `project` function walks the AST, it gathers a list of functions that will need to be implemented by each actor's implementing module, as well as a list of top-level functions for each projection.
269
277
- This gathering is handled by the `WriterMonad` module, which provides the `monadic do ... end` form as well as `return` and `mzero`.
270
278
- Finally the macro generates modules for each actor under the `Chorex` module it generates.
271
279
@@ -366,7 +374,7 @@ defmodule Chorex do
366
374
end
367
375
```
368
376
369
-
You can see there’s a `Chorex.Alice` module and a `Chorex.Bob` module.
377
+
You can see there's a `Chorex.Alice` module and a `Chorex.Bob` module.
0 commit comments