@@ -54,8 +54,16 @@ type Manager struct {
5454 pendingStateChangeCh map [uid.ID ]chan * event.TasksStateChangedEvent
5555}
5656
57+ var (
58+ instance * Manager
59+ )
60+
61+ func ManagerInstance () * Manager {
62+ return instance
63+ }
64+
5765func NewEnvManager (tm * task.Manager , incomingEventCh <- chan event.Event ) * Manager {
58- envman : = & Manager {
66+ instance = & Manager {
5967 m : make (map [uid.ID ]* Environment ),
6068 taskman : tm ,
6169 incomingEventCh : incomingEventCh ,
@@ -66,22 +74,22 @@ func NewEnvManager(tm *task.Manager, incomingEventCh <-chan event.Event) *Manage
6674 go func () {
6775 for ;; {
6876 select {
69- case incomingEvent := <- envman .incomingEventCh :
77+ case incomingEvent := <- instance .incomingEventCh :
7078 switch typedEvent := incomingEvent .(type ) {
7179 case event.DeviceEvent :
72- envman .handleDeviceEvent (typedEvent )
80+ instance .handleDeviceEvent (typedEvent )
7381 case * event.TasksReleasedEvent :
7482 // If we got a TasksReleasedEvent, it must be matched with a pending
7583 // environment teardown.
76- if thisEnvCh , ok := envman .pendingTeardownsCh [typedEvent .GetEnvironmentId ()]; ok {
84+ if thisEnvCh , ok := instance .pendingTeardownsCh [typedEvent .GetEnvironmentId ()]; ok {
7785 thisEnvCh <- typedEvent
7886 close (thisEnvCh )
79- delete (envman .pendingTeardownsCh , typedEvent .GetEnvironmentId ())
87+ delete (instance .pendingTeardownsCh , typedEvent .GetEnvironmentId ())
8088 }
8189 case * event.TasksStateChangedEvent :
8290 // If we got a TasksStateChangedEvent, it must be matched with a pending
8391 // environment transition.
84- if thisEnvCh , ok := envman .pendingStateChangeCh [typedEvent .GetEnvironmentId ()]; ok {
92+ if thisEnvCh , ok := instance .pendingStateChangeCh [typedEvent .GetEnvironmentId ()]; ok {
8593 thisEnvCh <- typedEvent
8694 }
8795 default :
@@ -90,7 +98,7 @@ func NewEnvManager(tm *task.Manager, incomingEventCh <-chan event.Event) *Manage
9098 }
9199 }
92100 }()
93- return envman
101+ return instance
94102}
95103
96104func (envs * Manager ) GetActiveDetectors () system.IDMap {
0 commit comments