engine: graph, resources: Change Watch to use ctx

This is a general port. There are many optimizations and cleanups we can
do now that we have a proper context passed in. That's for a future
patch.
This commit is contained in:
James Shubin
2023-08-07 20:17:32 -04:00
parent 53a878bf61
commit 963393e3d9
37 changed files with 139 additions and 130 deletions

View File

@@ -102,11 +102,6 @@ type Init struct {
// Event sends an event notifying the engine of a possible state change.
Event func()
// DoneCtx returns a context that will cancel to signal to us that it's
// time for us to shutdown.
// TODO: this is temporary until Watch supports context directly.
DoneCtx context.Context
// Called from within CheckApply:
// Refresh returns whether the resource received a notification. This
@@ -200,8 +195,8 @@ type Res interface {
// Watch is run by the engine to monitor for state changes. If it
// detects any, it notifies the engine which will usually run CheckApply
// in response.
Watch() error
// in response. If the input context cancels, we must shutdown.
Watch(context.Context) error
// CheckApply determines if the state of the resource is correct and if
// asked to with the `apply` variable, applies the requested state.