Implementing a step barrier for the master

Now, let's take a look at the other half of the barrier implementation logic that runs on the master node. The masterStepBarrier type, the definition of which is given as follows, is admittedly more interesting as it contains the actual barrier synchronization logic:

type masterStepBarrier struct {    ctx context.Context    numWorkers int    waitCh map[proto.Step_Type]chan *proto.Step    notifyCh map[proto.Step_Type]chan *proto.Step}

One key difference is that the masterStepBarrier type defines two types of channels:

  • Wait channel: It is a channel for which the barrier monitors for incoming Step messages from workers.
  • Notify channel: It is a channel where remote worker streams will block waiting for a Step ...

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.