example

command
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 4 Imported by: 0

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 .

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL