func (mc *membershipCache) rehashDataStructureIds(ch chan *ID) {
	for { // ever...
		id, ok := <-ch
		if !ok {
			return
		}

		mc.logger.Infof("Finding new replicas for data structure [%s]", id.String())
		numReplicas := mc.membership.getNumReplicasForDataStructure(id)
		if numReplicas <= 0 {
			mc.logger.Errorf("Num replicas can't be zero or less: %d", numReplicas)
		}

		peers, err := mc.startRaftsRemotely(id, numReplicas)
		if err != nil {
			mc.logger.Errorf("Can't create replicas: %s", err.Error())
		}

		var buffer bytes.Buffer
		for _, peer := range peers {
			buffer.WriteString(peer.String())
			buffer.WriteString(", ")
		}
		mc.logger.Infof("New peers for data structure [%s] are: %s", id.String(), buffer.String())
	}
}
// this being called as we see nodes fail or leave the cluster
// it makes sure all data structures have enough replicas
this being called as we see nodes fail or leave the cluster
it makes sure all data structures have enough replicas
// this being called as we see nodes fail or leave the cluster // it makes sure all data structures have enough replicas
func (mc *membershipCache) rehashDataStructureIds(ch chan *ID) {
	for { 
		id, ok := <-ch
		if !ok {
			return
		}
		mc.logger.Infof("Finding new replicas for data structure [%s]", id.String())
		numReplicas := mc.membership.getNumReplicasForDataStructure(id)
		if numReplicas <= 0 {
			mc.logger.Errorf("Num replicas can't be zero or less: %d", numReplicas)
		}
		peers, err := mc.startRaftsRemotely(id, numReplicas)
		if err != nil {
			mc.logger.Errorf("Can't create replicas: %s", err.Error())
		}
		var buffer bytes.Buffer
		for _, peer := range peers {
			buffer.WriteString(peer.String())
			buffer.WriteString(", ")
		}
		mc.logger.Infof("New peers for data structure [%s] are: %s", id.String(), buffer.String())
	}
}
func ( mc * membershipCache ) rehashDataStructureIds ( ch chan * ID ) { for { id , ok := <- ch if ! ok { return } mc . logger . Infof ( " " , id . String ( ) ) numReplicas := mc . membership . getNumReplicasForDataStructure ( id ) if numReplicas <= 0 { mc . logger . Errorf ( " " , numReplicas ) } peers , err := mc . startRaftsRemotely ( id , numReplicas ) if err != nil { mc . logger . Errorf ( " " , err . Error ( ) ) } var buffer bytes . Buffer for _ , peer := range peers { buffer . WriteString ( peer . String ( ) ) buffer . WriteString ( " " ) } mc . logger . Infof ( " " , id . String ( ) , buffer . String ( ) ) } }
this being called as we see nodes fail or leave the cluster
it makes sure all data structures have enough replicas
this being called as we see nodes fail or leave the cluster it makes sure all data structures have enough replicas
// ever...