feat(watchdog): quarantine escalates to ask_owner; reinstate/retire resolve fail-safe (#45)
This commit is contained in:
1 parent
bf4844c010
commit
720352c45b
6 files changed
+207
-23
No files matched your search
+19
@@ -99,6 +99,25 @@ func (s *CrowStore) Len() int {
|
||||
return len(s.spun)
|
||||
}
|
||||
|
||||
// Remove deletes a spun crow from the registry (the owner's retire call,
|
||||
// #45). A name not in the registry is a no-op: the removal is idempotent.
|
||||
func (s *CrowStore) Remove(name string) error {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
i := slices.IndexFunc(s.spun, func(c SpunCrow) bool { return strings.EqualFold(c.Name, name) })
|
||||
if i < 0 {
|
||||
return nil
|
||||
}
|
||||
old := s.spun
|
||||
rest := slices.Clone(old)
|
||||
s.spun = slices.Delete(rest, i, i+1)
|
||||
if err := s.save(); err != nil {
|
||||
s.spun = old
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// save writes atomically. The caller holds s.mu.
|
||||
func (s *CrowStore) save() error {
|
||||
data, err := json.MarshalIndent(s.spun, "", " ")
|
||||
|
||||
Reference in new issue
Block a user