func doService(cluster *cluster, joinAddr string) { log, _ := l5g.GetLog(cluster.GetSelf().Name) log.Info("Cluster initialized. Starting service. We are NID: %d", cluster.GetSelf().Nid) gossipService := &GossipService{cluster, log} go gossipService.startGossip(joinAddr) restService := &RestService{cluster, log} go restService.startRestService() }
func (c *cluster) AddSelf(self Node) error { c.lock.Lock() if c.self != nil { c.lock.Unlock() return fmt.Errorf("AddSelf: self already initialized") } c.self = &self c.lock.Unlock() if err := c.addNodeInternal(&self); err != nil { c.lock.Lock() c.self = nil c.lock.Unlock() return err } c.lock.Lock() c.log, _ = l5g.GetLog(c.self.Name) c.lock.Unlock() return nil }