func RestAPI()

in nimo-shake/incr-sync/syncer.go [650:700]


func RestAPI() {
	type IncrSyncInfo struct {
		Get         uint64      `json:"records_get"`
		Write       uint64      `json:"records_write"`
		CkptTimes   uint64      `json:"checkpoint_times"`
		UpdateTimes interface{} `json:"checkpoint_update_times"`
		Error       string      `json:"error"`
	}

	type CheckpointInfo struct {
		UpdateTime      string `json:"update_time"`
		ApproximateTime string `json:"sync_approximate_time"`
		FatherShardId   string `json:"father_shard_id"`
		SequenceNumber  string `json:sequence_number`
	}

	utils.IncrSyncHttpApi.RegisterAPI("/metric", nimo.HttpGet, func([]byte) interface{} {
		ckpt, err := ckptWriterG.ExtractCheckpoint()
		if err != nil {
			return &IncrSyncInfo{
				Error: err.Error(),
			}
		}

		retCkptMap := make(map[string]map[string]interface{}, len(ckpt))
		for table, ckptShardMap := range ckpt {
			shardMap := make(map[string]interface{}, 1)
			for shard, ckptVal := range ckptShardMap {
				if ckptVal.Status != string(utils.StatusProcessing) {
					continue
				}

				shardMap[shard] = &CheckpointInfo{
					UpdateTime:      ckptVal.UpdateDate,
					FatherShardId:   ckptVal.FatherId,
					ApproximateTime: ckptVal.ApproximateTime,
					SequenceNumber:  ckptVal.SequenceNumber,
				}
			}
			retCkptMap[table] = shardMap
		}

		return &IncrSyncInfo{
			Get:         replMetric.Get(),
			Write:       replMetric.Success(),
			CkptTimes:   replMetric.CheckpointTimes,
			UpdateTimes: retCkptMap,
		}
	})

}