engine: resources: Cleanup this old code

This is equivalent and cleaner.
This commit is contained in:
James Shubin
2025-05-02 00:01:46 -04:00
parent 4b1548488d
commit 7c77efec1d

View File

@@ -209,10 +209,8 @@ func (obj *KVRes) Watch(ctx context.Context) error {
obj.init.Running() // when started, notify engine that we're running
var send = false // send event?
for {
select {
// NOTE: this part is very similar to the file resource code
case err, ok := <-ch:
if !ok { // channel shutdown
return nil
@@ -223,17 +221,12 @@ func (obj *KVRes) Watch(ctx context.Context) error {
if obj.init.Debug {
obj.init.Logf("event!")
}
send = true
case <-ctx.Done(): // closed by the engine to signal shutdown
return nil
}
// do all our event sending all together to avoid duplicate msgs
if send {
send = false
obj.init.Event() // notify engine of an event (this can block)
}
obj.init.Event() // notify engine of an event (this can block)
}
}