func (this *DefaultEngine) Heart(method string, parms map[string]string, body []byte) (map[string]string, error) { dtype, hastype := parms["type"] res := make(map[string]string) if !hastype { return nil, fmt.Errorf("parms error") } switch dtype { case "alive": res["status"] = "alive" case "addindex": this.Logger.Info("[INFO] body %v", string(body)) var nodeindex utils.NodeIndex if err := json.Unmarshal(body, &nodeindex); err != nil { this.Logger.Error("[ERROR] nodeindex json error %v", err) } this.Logger.Info("[INFO] nodeindex %v", nodeindex) nodeindex.Shard = make([]uint64, 0) local := fmt.Sprintf("%v:%v", this.LocalIP, this.LocalPort) for k, v := range nodeindex.ShardNodes { for _, s := range v { if local == s { indexname := fmt.Sprintf("%v_%v", nodeindex.IndexName, k) err := this.createIndex(indexname, utils.IDX_ROOT_PATH, nodeindex.IndexMapping) if err != nil { this.Logger.Error("[ERROR] create index error %v", err) res["status"] = err.Error() return res, nil } nodeindex.Shard = append(nodeindex.Shard, uint64(k)) go this.pullDetail(nodeindex.IndexName, k) } } } this.idxNodes[nodeindex.IndexName] = nodeindex res["status"] = "add index Success" default: res["status"] = "alive" } return res, nil }