Documentation
¶
Index ¶
- type Config
- type EnvironmentConfig
- type Options
- type Plugin
- func (p *Plugin) Boot(app *nimbus.App) error
- func (p *Plugin) Config() *Config
- func (p *Plugin) DefaultConfig() map[string]any
- func (p *Plugin) FailedStore() queue.FailedJobStore
- func (p *Plugin) Gate() func(*http.Context) bool
- func (p *Plugin) Redis() *redis.Client
- func (p *Plugin) Register(app *nimbus.App) error
- func (p *Plugin) RegisterRoutes(r *router.Router)
- func (p *Plugin) ViewsFS() fs.FS
- type QueueStats
- type Stats
- type SupervisorConfig
- type SupervisorDefaults
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Environments holds per-environment supervisor sets (e.g. "production", "local").
Environments map[string]EnvironmentConfig
// Defaults are merged into each supervisor.
Defaults SupervisorDefaults
// Waits is per-queue wait threshold in seconds for long-wait notifications (e.g. "redis:default" => 60).
Waits map[string]int
// Silenced job class names to hide from completed list.
Silenced []string
// SilencedTags hide jobs with any of these tags.
SilencedTags []string
}
Config is the top-level Horizon configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Laravel-like default for local development.
func (*Config) CurrentEnvironment ¶
CurrentEnvironment returns the environment name (e.g. from APP_ENV).
func (*Config) MergeSupervisor ¶
func (c *Config) MergeSupervisor(s SupervisorConfig) SupervisorConfig
MergeSupervisor merges Defaults into a supervisor config.
func (*Config) SupervisorsForCurrentEnv ¶
func (c *Config) SupervisorsForCurrentEnv() map[string]SupervisorConfig
SupervisorsForCurrentEnv returns supervisor configs for the current environment. If no match, tries "*" then "local".
type EnvironmentConfig ¶
type EnvironmentConfig struct {
Supervisors map[string]SupervisorConfig
}
EnvironmentConfig holds supervisors for one environment (e.g. APP_ENV=production).
type Options ¶
type Options struct {
// Config is the Horizon worker config (environments, supervisors). If nil, DefaultConfig() is used.
Config *Config
// Gate authorizes dashboard access. If nil, dashboard is allowed only when APP_ENV is not production or HORIZON_ENABLED=true.
Gate func(*http.Context) bool
// RedisURL enables failed job store and pause/continue state. If empty, failed jobs are not persisted.
RedisURL string
}
Options configures the Horizon plugin (Laravel-style).
type Plugin ¶
type Plugin struct {
nimbus.BasePlugin
// contains filtered or unexported fields
}
Plugin integrates a Horizon-style dashboard and optional failed job store.
func NewWithOptions ¶
NewWithOptions creates a Horizon plugin with the given options.
func (*Plugin) DefaultConfig ¶
DefaultConfig returns default configuration for Horizon.
func (*Plugin) FailedStore ¶
func (p *Plugin) FailedStore() queue.FailedJobStore
FailedStore returns the failed job store if Redis was configured.
func (*Plugin) Redis ¶
Redis returns the Redis client if RedisURL was set (for pause/continue, etc.).
func (*Plugin) Register ¶
Register registers the plugin views, queue observer, and optional failed job store.
func (*Plugin) RegisterRoutes ¶
RegisterRoutes mounts the Horizon dashboard routes (Laravel Horizon style).
type QueueStats ¶
type QueueStats struct {
Name string
Dispatched int64
Processed int64
Failed int64
Retried int64
Reclaimed int64
LastDispatched *time.Time
LastProcessed *time.Time
}
QueueStats holds metrics for a specific queue.
type Stats ¶
type Stats struct {
StartedAt time.Time
TotalDispatched int64
TotalProcessed int64
TotalFailed int64
TotalRetried int64
TotalReclaimed int64
PerQueue map[string]*QueueStats
// contains filtered or unexported fields
}
Stats holds in-memory queue statistics for the Horizon dashboard.
func (*Stats) JobDispatched ¶
func (s *Stats) JobDispatched(payload *queue.JobPayload)
JobDispatched implements queue.Observer.
func (*Stats) JobProcessed ¶
func (s *Stats) JobProcessed(payload *queue.JobPayload, err error)
JobProcessed implements queue.Observer.
func (*Stats) JobRetried ¶
func (s *Stats) JobRetried(payload *queue.JobPayload, nextDelay time.Duration)
JobRetried implements queue.RetryObserver.
func (*Stats) JobsReclaimed ¶
JobsReclaimed implements queue.ReclaimObserver.
type SupervisorConfig ¶
type SupervisorConfig struct {
// Connection name (e.g. "redis").
Connection string
// Queue names this supervisor processes.
Queue []string
// Balance: "auto", "simple", or "false" (strict order).
Balance string
// Auto/simple: total process count. Simple splits evenly across queues.
Processes int
// Auto: min processes per queue.
MinProcesses int
// Auto/false: max total processes.
MaxProcesses int
// Auto: max processes to add/remove per balance step.
BalanceMaxShift int
// Auto: seconds between balance steps.
BalanceCooldown int
// Max job attempts (0 = unlimited). Job $tries overrides if set.
Tries int
// Job timeout in seconds (force kill worker).
Timeout int
// Backoff in seconds before retry, or nil for default.
Backoff []int
// Force run in maintenance mode when true.
Force bool
}
SupervisorConfig defines a group of workers (Laravel "supervisor").
func (*SupervisorConfig) BackoffDuration ¶
func (s *SupervisorConfig) BackoffDuration(attempt int) time.Duration
BackoffDuration returns the delay before retry for the given attempt (1-based).