Right now, the master waits for all the modules of a given phase using a counter and go channels:
|
// Waiting for modules' responses. |
|
// Apparently, we cannot wait for multiple messages belonging to different queues. |
|
// However, it makes sense for Quartermaster to wait only for messages belonging |
|
// to the current phase (i.e., builder, analysis, report). |
|
// The master consumes messages following that order. |
|
allModulesHaveResponded := make(chan bool) |
|
remainingModules := len(modulesToWakeUp) |
|
consumeModuleResponse(ch, &builderResponseQueue, allModulesHaveResponded, &remainingModules) |
|
consumeModuleResponse(ch, &analyzerResponseQueue, allModulesHaveResponded, &remainingModules) |
|
consumeModuleResponse(ch, &reporterResponseQueue, allModulesHaveResponded, &remainingModules) |
|
|
|
<-allModulesHaveResponded |
The counter is being decremented in the module response callback:
|
*remainingModules -= 1 |
|
if *remainingModules == 0 { |
|
finalModuleHasResponded <- true |
|
} |
Is there a better way to handle this?
Right now, the master waits for all the modules of a given phase using a counter and go channels:
broker-test/master/master.go
Lines 123 to 134 in dbc4cbb
The counter is being decremented in the module response callback:
broker-test/master/master.go
Lines 69 to 72 in dbc4cbb
Is there a better way to handle this?