Documentation
¶
Overview ¶
Package queuedashboard monitors togo queue jobs (Laravel Horizon / Sidekiq Web for togo): it records job lifecycle events, aggregates throughput / latency / failure stats, and exposes a REST + Go API to inspect, retry and delete jobs.
The togo Queue interface is Handle/Dispatch only, so the dashboard observes jobs by wrapping their handlers:
qd, _ := queuedashboard.FromKernel(k)
k.Queue.Handle("emails", qd.Wrap("emails", "send", sendEmail))
Wrapped handlers record running → done/failed with duration; RecordDispatch records an enqueue. Retry re-dispatches a recorded job over the kernel Queue.
Index ¶
- Constants
- type Filter
- type Job
- type QueueStat
- type Service
- func (s *Service) Delete(id string) bool
- func (s *Service) Get(id string) (Job, bool)
- func (s *Service) Jobs(f Filter) []Job
- func (s *Service) RecordDispatch(queue, jobType string, payload any) string
- func (s *Service) Retry(ctx context.Context, id string) error
- func (s *Service) Stats() []QueueStat
- func (s *Service) Wrap(queue, jobType string, h togo.QueueHandler) togo.QueueHandler
Constants ¶
const ( StatusQueued = "queued" StatusRunning = "running" StatusDone = "done" StatusFailed = "failed" StatusRetried = "retried" )
Job status values.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct {
ID string `json:"id"`
Queue string `json:"queue"`
Type string `json:"type"`
Status string `json:"status"`
Attempts int `json:"attempts"`
Payload any `json:"payload,omitempty"`
Queued time.Time `json:"queued"`
Started *time.Time `json:"started,omitempty"`
Finished *time.Time `json:"finished,omitempty"`
Duration int64 `json:"duration_ms,omitempty"`
Error string `json:"error,omitempty"`
}
Job is a recorded queue job and its current state.
type QueueStat ¶
type QueueStat struct {
Queue string `json:"queue"`
Total int `json:"total"`
Done int `json:"done"`
Failed int `json:"failed"`
Running int `json:"running"`
Queued int `json:"queued"`
FailureRate float64 `json:"failure_rate"`
AvgMs int64 `json:"avg_ms"`
}
QueueStat is aggregate health for a queue.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the dashboard runtime stored on the kernel (k.Get("queue-dashboard")).
func FromKernel ¶
FromKernel returns the dashboard Service registered on the kernel.
func (*Service) RecordDispatch ¶
RecordDispatch records an enqueued job and returns its id.
func (*Service) Retry ¶
Retry re-dispatches a recorded job over the kernel Queue (best with failed jobs).
func (*Service) Wrap ¶
func (s *Service) Wrap(queue, jobType string, h togo.QueueHandler) togo.QueueHandler
Wrap returns a QueueHandler that records running → done/failed with duration. Use it when registering a handler: k.Queue.Handle(name, qd.Wrap(name, type, h)).