Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source.Channel gets a nil value for stop channel #149

Closed
mhrivnak opened this issue Sep 18, 2018 · 1 comment
Closed

source.Channel gets a nil value for stop channel #149

mhrivnak opened this issue Sep 18, 2018 · 1 comment

Comments

@mhrivnak
Copy link
Contributor

Problem

When adding a Channel to a controller by calling Watch(), InjectStopChannel gets called with a value of nil instead of a real channel.

This appears to be because nothing sets the value of stop before Watch() gets called. The value of stop only gets set once the manager's Start() method is called.

Here's the order of operations:

  1. Manager gets created
  2. Controller gets created and added to the manager
  3. Controller's Watch() method gets called with the new Channel as an argument
  4. Manager's Start() method gets called, with a stop channel being passed in. This is the opportunity for a stop channel to be provided by a controller author.
  5. The manager's Start() method calls each controller's Start() method, also passing through the stop channel.

At step 3, the manager's stop channel gets injected into the Channel. But the manager's stop channel doesn't get set until step 4, so at step 3 it has a nil value.

Workaround

The controller author can call InjectStopChannel directly and pass it the same channel they'll later pass to the manager's Start() method. But the InjectStopChannel method is clearly documented as not being intended for this purpose, nor is this approach helpful to the controller author.

@DirectXMan12
Copy link
Contributor

duplicate of #103

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants