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" 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.