Explorar el Código

update peerUpdate to trigger pull

Max Ma hace 1 año
padre
commit
446fcfb250
Se han modificado 2 ficheros con 9 adiciones y 6 borrados
  1. 2 0
      models/host.go
  2. 7 6
      mq/publishers.go

+ 2 - 0
models/host.go

@@ -116,6 +116,8 @@ const (
 	UpdateKeys HostMqAction = "UPDATE_KEYS"
 	// RequestPull - request a pull from a host
 	RequestPull HostMqAction = "REQ_PULL"
+	// JoinPull - request a pull from a host without restart
+	JoinPull HostMqAction = "JOIN_PULL"
 	// UpdateMetrics - updates metrics data
 	UpdateMetrics HostMqAction = "UPDATE_METRICS"
 )

+ 7 - 6
mq/publishers.go

@@ -24,15 +24,16 @@ func PublishPeerUpdate(replacePeers bool) error {
 		logger.Log(1, "err getting all hosts", err.Error())
 		return err
 	}
-	allNodes, err := logic.GetAllNodes()
-	if err != nil {
-		return err
-	}
+
 	for _, host := range hosts {
 		host := host
 		go func(host models.Host) {
-			if err = PublishSingleHostPeerUpdate(&host, allNodes, nil, nil, replacePeers); err != nil {
-				logger.Log(1, "failed to publish peer update to host", host.ID.String(), ": ", err.Error())
+			hostUpdate := models.HostUpdate{
+				Action: models.JoinPull,
+				Host:   host,
+			}
+			if err = HostUpdate(&hostUpdate); err != nil {
+				slog.Warn("failed to send host pull request", "host", host.ID.String(), "error", err)
 			}
 		}(host)