This application demonstrates using Temporal by calling two APIs in sequence. It fetches the user's IP address and then uses that address to geolocate that user.
You can use the app in two ways:
- Through a web front-end
- Through a JSON POST request
In both cases, you provide a name that's included in the greeting.
The app requires the Temporal Service.
First, Install the Temporal CLI
Install the dependencies for the project:
bundle installThen, in another terminal window, start the Temporal Service locally using a database to persist data between runs:
$ temporal server start-dev --db-filename temporal.dbNow launch a new terminal window and start the Temporal Worker:
bundle exec ruby lib/worker.rbIn a new terminal window, run the client app to start the Workflow:
bundle exec ruby lib/client.rb AngelaIn a third terminal window, start the web server to handle API and web requests:
bundle exec ruby -S rackup server/config.ru -p 3000 -o 0.0.0.0Now visit http://localhost:3000 and enter your name to run the Workflow.
You can also issue a cURL request to start the Workflow:
curl -X POST http://localhost:3000/api -H "Content-Type: application/json" -d '{"name":"Angela Zhou"}'Visit http://localhost:8233 to view the Event History in the Temporal UI.
Disable your internet connection and try again. This time you'll see the Workflow pause. Restore the internet connection and the Workflow completes.