ax(mining): replace prose comments with usage examples in supervisor
Four exported methods on TaskSupervisor had comments restating the signature (AX §2 violation). Replaced with concrete call-site examples. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
3aa83c3e2b
commit
654a3e43c6
1 changed files with 4 additions and 4 deletions
|
|
@ -58,7 +58,7 @@ func (s *TaskSupervisor) RegisterTask(name string, task TaskFunc, restartDelay t
|
|||
}
|
||||
}
|
||||
|
||||
// Start starts all registered tasks.
|
||||
// supervisor.Start() // begins all registered tasks; no-op if already started
|
||||
func (s *TaskSupervisor) Start() {
|
||||
s.mu.Lock()
|
||||
if s.started {
|
||||
|
|
@ -143,7 +143,7 @@ func (s *TaskSupervisor) startTask(name string, st *SupervisedTask) {
|
|||
logging.Info("started supervised task", logging.Fields{"task": name})
|
||||
}
|
||||
|
||||
// Stop stops all supervised tasks.
|
||||
// supervisor.Stop() // cancels all tasks and waits for clean exit
|
||||
func (s *TaskSupervisor) Stop() {
|
||||
s.cancel()
|
||||
s.waitGroup.Wait()
|
||||
|
|
@ -160,7 +160,7 @@ func (s *TaskSupervisor) Stop() {
|
|||
logging.Info("task supervisor stopped")
|
||||
}
|
||||
|
||||
// GetTaskStatus returns the status of a task.
|
||||
// running, restarts, ok := supervisor.GetTaskStatus("stats-collector")
|
||||
func (s *TaskSupervisor) GetTaskStatus(name string) (running bool, restartCount int, found bool) {
|
||||
s.mu.RLock()
|
||||
task, ok := s.tasks[name]
|
||||
|
|
@ -175,7 +175,7 @@ func (s *TaskSupervisor) GetTaskStatus(name string) (running bool, restartCount
|
|||
return task.running, task.restartCount, true
|
||||
}
|
||||
|
||||
// GetAllTaskStatuses returns status of all tasks.
|
||||
// for name, status := range supervisor.GetAllTaskStatuses() { log(name, status.Running) }
|
||||
func (s *TaskSupervisor) GetAllTaskStatuses() map[string]TaskStatus {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue