January 2020
Intermediate to advanced
640 pages
16h 56m
English
Next, we will move to the worker side and examine the equivalent stream helper for handling a connection to the master node. The definition of the remoteMasterStream type is pretty much the same as remoteWorkerStream, given as follows:
type remoteMasterStream struct { stream proto.JobQueue_JobStreamClient recvMsgCh chan *proto.MasterPayload sendMsgCh chan *proto.WorkerPayload ctx context.Context cancelFn func() mu sync.Mutex onDisconnectFn func() disconnected bool}Once the worker connects to the master node and receives a job assignment, it will invoke the newRemoteMasterStream function to wrap the obtained stream connection with a remoteMasterStream instance:
func newRemoteMasterStream(stream proto.JobQueue_JobStreamClient) ...