Skip to Content
Hands-On Software Engineering with Golang
book

Hands-On Software Engineering with Golang

by Achilleas Anagnostopoulos
January 2020
Intermediate to advanced
640 pages
16h 56m
English
Packt Publishing
Content preview from Hands-On Software Engineering with Golang

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Software Architecture with Golang

Hands-On Software Architecture with Golang

Jyotiswarup Raiturkar

Publisher Resources

ISBN: 9781838554491Supplemental Content