resources, pgraph: Refactor Worker and simplify API
I'm still working on reducing the size of the monster patches that I land, but I'm exercising the priviledge as the initial author. In any case, this refactors worker into two, and cleans up the passing around of the processChan. This puts common code into Init and Close.
This commit is contained in:
@@ -273,7 +273,7 @@ sending out erroneous `Event` messages to keep things alive until it finishes.
|
||||
#### Example
|
||||
```golang
|
||||
// Watch is the listener and main loop for this resource.
|
||||
func (obj *FooRes) Watch(processChan chan *event.Event) error {
|
||||
func (obj *FooRes) Watch() error {
|
||||
// setup the Foo resource
|
||||
var err error
|
||||
if err, obj.foo = OpenFoo(); err != nil {
|
||||
@@ -282,7 +282,7 @@ func (obj *FooRes) Watch(processChan chan *event.Event) error {
|
||||
defer obj.whatever.CloseFoo() // shutdown our
|
||||
|
||||
// notify engine that we're running
|
||||
if err := obj.Running(processChan); err != nil {
|
||||
if err := obj.Running(); err != nil {
|
||||
return err // bubble up a NACK...
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ func (obj *FooRes) Watch(processChan chan *event.Event) error {
|
||||
// do all our event sending all together to avoid duplicate msgs
|
||||
if send {
|
||||
send = false
|
||||
obj.Event(processChan)
|
||||
obj.Event() // send the event!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user