Documentation
¶
Index ¶
- type Dashboard
- func (d *Dashboard) Clear()
- func (d *Dashboard) Entries() []DashboardEntry
- func (d *Dashboard) Subscribe() (<-chan DashboardEntry, func())
- func (d *Dashboard) Track(typ, message string, data any)
- func (d *Dashboard) TrackEvent(name string, payload any)
- func (d *Dashboard) TrackJob(name, status string, data any, duration time.Duration)
- func (d *Dashboard) TrackLog(level, message string, data any)
- func (d *Dashboard) TrackMail(to, subject string, data any)
- func (d *Dashboard) TrackQuery(query string, args []any, duration time.Duration)
- func (d *Dashboard) TrackRedis(command string, args any, duration time.Duration)
- func (d *Dashboard) TrackRequest(method, path string, status int, duration time.Duration)
- type DashboardEntry
- type LogHandler
- type QueueMonitor
- func (m *QueueMonitor) PurgeQueue(ctx context.Context, name string) (int64, error)
- func (m *QueueMonitor) QueueStats(ctx context.Context) ([]QueueStat, error)
- func (m *QueueMonitor) RegisterQueue(name string)
- func (m *QueueMonitor) RetryFailed(ctx context.Context, queueName string) (int64, error)
- func (m *QueueMonitor) ScheduledJobs(ctx context.Context, queueName string, n int) ([]ScheduledJob, error)
- func (m *QueueMonitor) TotalFailed(ctx context.Context) int64
- type QueueStat
- type ScheduledJob
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dashboard ¶
type Dashboard struct {
// contains filtered or unexported fields
}
Dashboard manages the in-memory observability data for developers.
func NewDashboard ¶
NewDashboard creates a new Dashboard service.
func (*Dashboard) Entries ¶
func (d *Dashboard) Entries() []DashboardEntry
Entries returns a copy of the recent dashboard entries.
func (*Dashboard) Subscribe ¶
func (d *Dashboard) Subscribe() (<-chan DashboardEntry, func())
Subscribe returns a channel that receives new dashboard entries. The caller must call the returned unsubscribe function when done.
func (*Dashboard) TrackEvent ¶
TrackEvent adds a framework event entry to the dashboard.
func (*Dashboard) TrackQuery ¶
TrackQuery adds a database query entry to the dashboard.
func (*Dashboard) TrackRedis ¶
TrackRedis adds a Redis command entry to the dashboard.
type DashboardEntry ¶
type DashboardEntry struct {
ID int64 `json:"id"`
Timestamp time.Time `json:"timestamp"`
Type string `json:"type"` // "event", "log", "http", "query", "job", "mail", "redis"
Category string `json:"category"` // more specific e.g. "auth", "db", "cache"
Level string `json:"level,omitempty"`
Message string `json:"message"`
Data any `json:"data,omitempty"`
Duration int64 `json:"duration_ms,omitempty"`
}
DashboardEntry represents a single item in the dev dashboard.
type LogHandler ¶
LogHandler is a slog.Handler that pushes records to the dashboard.
func NewLogHandler ¶
func NewLogHandler(h slog.Handler, dash *Dashboard) *LogHandler
NewLogHandler wraps an existing slog.Handler.
type QueueMonitor ¶
type QueueMonitor struct {
// contains filtered or unexported fields
}
QueueMonitor introspects the Redis data structures used by the Astra Queue package to provide real-time visibility into queue depth and failures.
It supports three queue key patterns (all configurable via KeyPrefix):
- List <prefix>:<name> — main pending queue (LLEN)
- List <prefix>:<name>:retry — in-flight / processing
- List <prefix>:<name>:failed — dead-letter list
- ZSet <prefix>:<name>:delayed — scheduled future jobs (ZCARD)
func NewQueueMonitor ¶
func NewQueueMonitor(client goredis.UniversalClient, keyPrefix string, queueNames ...string) *QueueMonitor
NewQueueMonitor creates a QueueMonitor backed by the provided Redis client. keyPrefix should match the prefix used by the queue package (default: "astra:queue"). queueNames is the list of queue names to monitor (e.g. ["default", "mail", "notifications"]).
func (*QueueMonitor) PurgeQueue ¶
PurgeQueue removes all pending jobs from a specific queue (destructive!).
func (*QueueMonitor) QueueStats ¶
func (m *QueueMonitor) QueueStats(ctx context.Context) ([]QueueStat, error)
QueueStats polls Redis and returns current stats for all registered queues. The call is synchronous and typically completes in < 1ms for local Redis.
func (*QueueMonitor) RegisterQueue ¶
func (m *QueueMonitor) RegisterQueue(name string)
RegisterQueue adds a queue name to the monitor's watch list.
func (*QueueMonitor) RetryFailed ¶
RetryFailed moves all failed jobs back to the pending queue for re-processing. queueName must match a registered queue. Passing "" retries all queues.
func (*QueueMonitor) ScheduledJobs ¶
func (m *QueueMonitor) ScheduledJobs(ctx context.Context, queueName string, n int) ([]ScheduledJob, error)
ScheduledJobs returns the first n jobs from the delayed sorted-set for a queue.
func (*QueueMonitor) TotalFailed ¶
func (m *QueueMonitor) TotalFailed(ctx context.Context) int64
TotalFailed returns the total number of failed jobs across all queues.
type QueueStat ¶
type QueueStat struct {
Name string `json:"name"`
Pending int64 `json:"pending"` // jobs waiting to be processed
Processing int64 `json:"processing"` // jobs currently in-flight (reserved)
Failed int64 `json:"failed"` // jobs in the dead-letter list
Scheduled int64 `json:"scheduled"` // jobs in the delayed sorted-set
LastPolled string `json:"last_polled"`
}
QueueStat holds aggregate stats for a single named queue.