Documentation
¶
Overview ¶
Counter is a reference example for funtask.
It registers three tasks that showcase different patterns:
- greet — instant success with parameters
- fail-demo — instant failure with a custom error code
- countdown — long-running task with progress reporting
The dashboard (enabled with WithDashboard) provides a browser UI at /dashboard for triggering tasks, watching progress, and inspecting errors. Open http://localhost:8080/dashboard after starting the server.
Usage:
export FUNTASK_AUTH_TOKEN=secret
export FUNTASK_DEAD_LETTER_DIR=/tmp/dead-letters
mkdir -p $FUNTASK_DEAD_LETTER_DIR
go run ./example
# Open the dashboard:
open http://localhost:8080/dashboard
# Or use curl — sync request (blocks until done):
curl -H "Authorization: Bearer secret" \
-d '{"params":{"start":5}}' localhost:8080/run/countdown
# Async request with callback:
curl -H "Authorization: Bearer secret" \
-d '{"params":{"start":5},"callbackUrl":"https://hooks.example.com/done"}' \
localhost:8080/run/countdown
# Check progress while running:
curl -H "Authorization: Bearer secret" localhost:8080/health | jq .
Click to show internal directories.
Click to hide internal directories.