Remote worker stream

remoteWorkerStream, the definition of which is shown in the following listing, is used by the master to wrap an incoming worker connection:

type remoteWorkerStream struct {    stream proto.JobQueue_JobStreamServer    recvMsgCh chan *proto.WorkerPayload    sendMsgCh chan *proto.MasterPayload    sendErrCh chan error    mu sync.Mutex    onDisconnectFn func()    disconnected bool}

As you can see in the preceding code, remoteWorkerStream defines three channels for interacting with the stream:

  • recvMsgCh is used for receiving payloads sent in by the worker.
  • sendMsgCh is used for sending payloads from the master to the worker.
  • sendErrCh allows the master to disconnect the worker connection with or without an error code.

The code that interacts ...

Get Hands-On Software Engineering with Golang now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.