moon add Milky2018/moonchorCheck examples
trait Location: Show + Hash {
name(Self) -> String
}
fn make_local_backend(
locations : Array[&Location],
logger~ : &Logger = make_mute_logger()
) -> Backend
async fn run_choreo[T, L : Location](
backend : Backend,
choreography : (ChoreoContext) -> T!Async,
role : L,
logger? : &Logger
) -> T For example, you can define some roles/locations by implementing the Location trait:
struct Alice {}
struct Bob {}
impl Location for Alice with name(_) { "Alice" }
impl Location for Bob with name(_) { "Bob" }
let alice : Alice = Alice::{ }
let bob : Bob = Bob::{ }Define a simple choreography: Alice --msg-> Bob
async fn simple_choreo(ctx: ChoreoContext) -> Unit {
let msg_at_alice = ctx.locally(alice, fn (_) { "Hello" })
let msg_at_bob = ctx.comm(alice, bob, msg_at_alice)
ctx.locally(bob, fn (unwrapper) { println(unwrapper.unwrap(msg_at_bob)) })
}Then you can run the choreography:
let backend = make_local_backend([alice, bob])
run_choreo!(backend, simple_choreo, alice)
// or run_choreo!(backend, simple_choreo, bob)- README
- HTTP backend
- Choice of knowledge
- Enclave
- Logging update
- Async support