예제 #1
0
func TestSequentialCount32(t *testing.T) {
	if nil == centerAgent {
		t.Errorf("Failed to connect zk_test:2181 or redis_test:6379")
	}
	numberNextMax, err := count.SequentialCount(centerAgent, "php-biz", 1, 0, 9999, 3)
	if err != nil {
		t.Errorf("Failed to count sequential: " + err.Error())
	}

	t.Errorf(numberNextMax)
}
예제 #2
0
func TestSequentialCount64(t *testing.T) {
	if nil == centerAgent {
		t.Errorf("Failed to connect zk_test:2181 or redis_test:6379")
	}
	numberNextMin, err := count.SequentialCount(centerAgent, "cpp-biz", -1, 9999, 0, 3)
	if err != nil {
		t.Errorf("Failed to count sequential: " + err.Error())
	}

	t.Errorf("64: " + numberNextMin)

}
예제 #3
0
파일: Generator.go 프로젝트: zbs4ms/ids
func (u *UUIDGenerator) GetPrimaryID32(bizCode string, token string, max int64, num int16) (r *uuid.UUIDResponse, err error) {
	check := checkRequest(bizCode, token, num)
	if check != nil {
		return check, nil
	}
	numberNextMax, err := count.SequentialCount(global.CoordinateCenter, bizCode, 1, 0, max, num)
	if err != nil {
		return resultErrorUnknown, nil
	}

	result := make([]string, num)
	v, err := strconv.ParseInt(numberNextMax, 10, 64)
	var i int16
	for i = 0; i < num; i++ {
		result[i] = strconv.FormatInt(v-(int64(num)-int64(i)-1), 10)
	}

	return &uuid.UUIDResponse{uuid.ResponseCode_OK, "", result}, nil
}