This repository contains a simple application which showcases how to use the Hatchet Go SDK to create events and workflows. In ./cmd/server, you'll find a simple echo
server which pushes an event to Hatchet every time it receives a request on /test
. In ./cmd/worker, we create a worker which runs a simple workflow called event-test
whenever the test-called
event is seen.
This quickstart example requires the following tools to work:
go 1.18+
docker
-
Run
go mod download
to fetch all packages. -
Run
docker compose up
to start the Hatchet instance. This will take a few minutes, as the docker compose services set up the database and generate the required certificates to connect to the Hatchet instance. You can also rundocker compose up -d
to start this in the background. Once you start to see output from theengine
andapi
services, you can move on to the next step. -
You should be able to navigate to localhost:8080 and use the following credentials to log in:
Email: [email protected] Password: Admin123!!
-
Create a token. You can do this from the dashboard or from the CLI:
From the CLI:
export HATCHET_CLIENT_TOKEN="$(docker compose run --no-deps setup-config /hatchet/hatchet-admin token create --config /hatchet/config --tenant-id 707d0855-80ab-4e1f-a156-f1c4546cbf52 | xargs)"
echo "HATCHET_CLIENT_TOKEN=$HATCHET_CLIENT_TOKEN" > .env
From the dashboard:
- Navigate to the token page and create a token.
- Click the copy to clipboard button and paste into a new file called
.env
in the root of this repository.
- Start the server and worker:
trap "pkill -P $$" EXIT; go run ./cmd/server & go run ./cmd/worker
- Run
curl http://localhost:1323/test
to test the endpoint.
You will see events and workflows populated in the Hatchet dashboard: