Horizon — Queue Dashboard
Laravel-style queue dashboard: in-memory throughput stats, optional Redis-backed failed jobs, live Redis queue depths (pending / delayed / processing / in-flight), Prometheus metrics, and a configurable Gate for production.
§ Overview
- Dashboard HTML under
HORIZON_PATH(default/horizon). - Observer hooks increment global Prometheus counters (same registry as
/metrics). - With
Options.RedisURL(typicallyREDIS_URL): failed job persistence + Horizon UI for list / forget / retry. - Same Redis client powers live workloads on the Pending page and
GET …/api/workloadsusing the same keys asqueue.RedisAdapter. HORIZON_QUEUES— comma-separated queue names to always include in workload snapshots (even before traffic hits the observer).
§ Installation
$ nimbus plugin:install horizon
Or register manually in bin/server.go:
import (
"os"
"github.com/CodeSyncr/nimbus/plugins/horizon"
)
app.Use(horizon.NewWithOptions(horizon.Options{
RedisURL: os.Getenv("REDIS_URL"),
Gate: nil, // optional: func(*http.Context) bool
}))
§ Environment
| Variable | Purpose |
|---|---|
HORIZON_PATH | Dashboard base path |
HORIZON_ENABLED | Set true to allow the dashboard when APP_ENV=production |
REDIS_URL | Pass into Options.RedisURL for failed store + live workloads |
HORIZON_QUEUES | Extra queue names for workload probes (comma-separated) |
§ Worker config (horizon.Config)
Code-driven supervisors (environments, balance strategies, tries, timeout, backoff) live on github.com/CodeSyncr/nimbus/plugins/horizon. Pass a pointer via horizon.Options{ Config: &cfg } or use horizon.DefaultConfig(). Fields match Laravel-style naming: Environments, SupervisorConfig with Balance auto / simple / false, etc.
§ Failed jobs
When Redis is configured, the plugin registers queue.SetFailedJobStore. Failed jobs appear under Failed in the UI. From code, use queue.GetFailedJobStore() after boot (same interface the dashboard uses).
§ HTTP routes (relative to HORIZON_PATH)
| Method | Path | Description |
|---|---|---|
GET | / | Dashboard |
GET | /pending | Pending + live Redis workloads (when Redis configured) |
GET | /api/metrics | JSON stats snapshot |
GET | /api/workloads | Redis depth JSON (requires RedisURL) |
GET | /api/metrics/prometheus | Prometheus text exposition |
GET | /api/failed | List failed jobs (JSON) |
POST | /failed/:id/forget | Forget one failed job |
POST | /failed/forget-all | Forget all |
POST | /failed/:id/retry | Re-queue a failed job |
§ Programmatic queue depths
Outside Horizon, use the core queue helper with a github.com/CodeSyncr/nimbus/redis client:
workloads, err := queue.RedisQueueWorkloads(ctx, rdb, []string{"default", "emails"})
See also: Queue, Production readiness, Reverb (WebSockets).