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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.