Getting Started
Read how to get started with Tempo.
Playground
The Tempo Playground is an online editor for Tempo. You can run some of the provided examples and simulate their execution, or modify the code to learn and experiment. The playground will highlight errors and show you the generated output code.
Installation
To install Tempo, you first need to have Go installed. To build and install Tempo on your machine, run the following command.
$ go install github.com/tempo-lang/tempo@latest
To check that Tempo is successfully installed, run the tempo
command in the terminal.
Tip
We recommended installing the vscode extension for language support in the editor.
Your first choreography
Now where you have successfully installed Tempo, we can test it by writing the hello world example for choreographies.
Create a new file with the following code and name it greeting.tempo
.
func@(Alice, Bob) greet() {
Alice->Bob "Hello Bob, this is Alice";
Bob->Alice "Hi Alice, nice to meet you";
}
In a terminal, navigate to the directory of the file and run this command to build the choreography.
$ tempo build greeting.tempo
You should obtain the following projected Go code.
// Projection of choreography greet
func greet_Alice(env *runtime.Env) {
runtime.Send(env, "Hello Bob, this is Alice", "Bob")
_ = runtime.Recv[string](env, "Bob")
}
func greet_Bob(env *runtime.Env) {
_ = runtime.Recv[string](env, "Alice")
runtime.Send(env, "Hi Alice, nice to meet you", "Alice")
}
The function has been projected to two functions, the one from the perspective of Alice
and Bob
respectively.
Notice that in greet_Alice
, the function first sends a message and then receives a reply,
and for greet_Bob
the same thing happens but in reverse.