Documentation
¶
Overview ¶
Package servicecommands stores small, allowlisted service control requests.
Index ¶
- Constants
- Variables
- type Manager
- func (m *Manager) ConsumeNext(targetService, consumedBy string, now time.Time) (ServiceCommand, bool, error)
- func (m *Manager) Get(commandID string) (ServiceCommand, error)
- func (m *Manager) MarkRecovered(targetService, recoveredBy string, now time.Time) (int64, error)
- func (m *Manager) Request(targetService, action, requestedBy, requestedFrom string, ttl time.Duration) (ServiceCommand, error)
- func (m *Manager) RequestRestart(targetService, requestedBy, requestedFrom string, ttl time.Duration) (ServiceCommand, error)
- type ServiceCommand
Constants ¶
View Source
const ( ActionRestart = "restart" // ActionPersistConfig asks a service to write its DB-edited config // sections back to its own YAML file. Unlike a restart it does not // change what the running process is using — only what is on disk. ActionPersistConfig = "persist-config" // ActionReloadLogSinks asks osctrl-tls to rebuild its per-environment // log sink exporter map from the log_sinks table and swap it in // without restarting. In-flight logs to the old sinks may be dropped // during the swap; the old sinks are closed immediately after the // new set is live. ActionReloadLogSinks = "reload-log-sinks" // ActionReloadAuthProviders asks osctrl-api to rebuild its // auth provider registry from the auth_providers table and swap // it in without restarting. Users mid-login may see a transient // error and can retry. ActionReloadAuthProviders = "reload-auth-providers" // ActionReloadAlerts asks osctrl-tls to reload its alert rule // snapshot and reset the channel sender cache without restarting. // The swap is atomic (copy-on-write snapshot), so in-flight matches // finish against the old ruleset while new logs pick up the new one. ActionReloadAlerts = "reload-alerts" StatusPending = "pending" StatusConsumed = "consumed" StatusRecovered = "recovered" StatusExpired = "expired" )
Variables ¶
View Source
var ( ErrInvalidTarget = errors.New("invalid service command target") ErrInvalidAction = errors.New("invalid service command action") )
Functions ¶
This section is empty.
Types ¶
type Manager ¶
Manager manages service_commands.
func NewManager ¶
func (*Manager) ConsumeNext ¶
func (m *Manager) ConsumeNext(targetService, consumedBy string, now time.Time) (ServiceCommand, bool, error)
ConsumeNext claims the oldest pending command for the service, whatever its action. The caller dispatches on cmd.Action — actions are allowlisted at request time, so anything returned here is one the consumer knows.
func (*Manager) MarkRecovered ¶
func (*Manager) Request ¶
func (m *Manager) Request(targetService, action, requestedBy, requestedFrom string, ttl time.Duration) (ServiceCommand, error)
Request enqueues a one-shot command for a service to consume on its next poll.
func (*Manager) RequestRestart ¶
type ServiceCommand ¶
type ServiceCommand struct {
gorm.Model
CommandID string `gorm:"uniqueIndex"`
TargetService string `gorm:"index:idx_service_commands_pending"`
Action string `gorm:"index:idx_service_commands_pending"`
RequestedBy string
RequestedFrom string
ConsumedAt *time.Time `gorm:"index:idx_service_commands_pending"`
ConsumedBy string
RecoveredAt *time.Time
RecoveredBy string
ExpiresAt time.Time `gorm:"index:idx_service_commands_pending"`
}
ServiceCommand is a one-shot control request for another osctrl service.
Click to show internal directories.
Click to hide internal directories.