syntaxsugar

Wordflow Temporal Course · Lessons

00 · Setup

Goal: get the Temporal Service, the web app, and the Temporal UI running, and find your way around the project.

What’s running

ProcessCommandPortWhat it does
Temporal Servicemake temporal7233, UI on 8233Stores Workflow state and hands out work. A dev server that keeps its data in .temporal/.
Web app and APImake server8080The game UI, the HTTP API, and fake external services.
Workermake workerRuns your Workflow and Activity code. You build it in Lesson 1.

The Temporal Service never runs your code. It records what happened and puts tasks on a Task Queue. Your Worker polls that queue, runs the code, and reports back.

Project layout

PathOwnerWhat
app/youEverything you write: Workflows, Activities, the Worker, and the API functions that call Temporal.
solutions/NN/courseThe finished app/ after each lesson.
internal/courseGame rules, puzzle storage, HTTP routing, fake services. You call these; you don’t change them.
web/courseThe browser app.
puzzles/courseOne JSON file per puzzle.
course/courseThese lessons.

Build it

1. Start the Temporal Service

The Codespace installs the Temporal CLI. In a terminal:

make temporal

Leave it running. Open the Ports tab and open port 8233 to see the Temporal UI.

2. Start the web app

In a second terminal:

make server

Port 8080 opens in your browser.

3. Look around

app/
  api/api.go          # one method per endpoint; all return ErrNotImplemented
  cmd/server/main.go  # starts the web app; you add a Temporal Client in Lesson 1
  cmd/worker/main.go  # you build the Worker in Lesson 1
internal/
  game/               # game rules: State, Player, Leaderboard
  puzzles/            # reads puzzles/*.json
  httpapi/            # routes, JSON, error mapping
  services/           # fake dictionary and feed

Open app/api/api.go. Each method is one endpoint and names the lesson that builds it. The HTTP layer in internal/httpapi decodes the request, calls your method, and turns its result or error into a response.

Skim internal/game/game.go. Its functions take the current time as an argument instead of calling time.Now(). You’ll see why in Lesson 1.

4. Useful commands

CommandWhat
make worker / make serverRun your code in app/.
make worker S=05Run Lesson 5’s solution.
make buildCompile and vet everything.
make clean-workflowsTerminate every running Workflow.
make reset-temporalDelete all Temporal data (stop make temporal first).
temporal workflow listList Workflows from the terminal.

Check it

  • The Temporal UI opens on port 8233 and shows the default namespace with no Workflows.

    Temporal UI with no Workflows

  • The web app opens on port 8080 and lists five puzzles.

  • Clicking a puzzle shows Not built yet. This arrives in Lesson 1.

  • The External services panel shows the dictionary mode and an empty feed.

    The starter web app

Working through the course

  • Keep three terminals open: make temporal, make server, and make worker.
  • Restart the Worker after changing Workflow or Activity code. Restart the server after changing API code.
  • Games from earlier lessons keep running with the code they started on. If the Worker logs errors about old Workflows, end them with make clean-workflows. Lesson 12 explains why this happens.
  • To compare with the finished code, run make worker S=NN and make server S=NN.
  • make reset-temporal (with make temporal stopped) deletes every Workflow and starts fresh.
  • The course site starts with the Codespace. If it isn’t on port 8000, run make course.

Edit this lesson on GitHub