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