Commits

Dave Cheney  committed 9dcd277

refactored

  • Participants
  • Parent commits 2d84d49

Comments (0)

Files changed (1)

File heartbeatd/main.go

 	ONE_SECOND = 1 * 1000 * 1000 * 1000
 )
 
-func main() {
+func mkAnnouncement() *openvz.Announcement {
+	return &openvz.Announcement { 
+		Zone: zone(), 
+		Area: area(), 
+		Host: host(), 
+		Sequence: nextSequence(),
+	 }
+}
+
+func setupSocket() *net.UDPConn {
 	BROADCAST, err := net.ResolveUDPAddr("255.255.255.255:7777")
 	if err != nil {
 		log.Exit("Address resolution error:", err)
 	if err != nil {
 		log.Exit("Unable to establish connection:", err)
 	}
+	return socket
+}
+
+func main() {
+	socket := setupSocket()
 	
 	for true {
-		ann := &openvz.Announcement { Zone: zone(), Area: area(), Host: host(), Sequence: nextSequence() }
+		ann := mkAnnouncement()
 
 		data, err := proto.Marshal(ann)
 		if err != nil {
 		}
 		
 		time.Sleep(ONE_SECOND)
-		
 	}
 }