Пример #1
0
func (pq *PQueue) tsParamFunc(params []string, f func(int64) int64) iface.IResponse {
	var err *common.ErrorResponse
	var ts int64 = -1
	for len(params) > 0 {
		switch params[0] {
		case PRM_TIMESTAMP:
			params, ts, err = common.ParseInt64Params(params, 0, math.MaxInt64)
		default:
			return makeUnknownParamResponse(params[0])
		}
		if err != nil {
			return err
		}
	}
	if ts < 0 {
		return common.ERR_TS_PARAMETER_NEEDED
	}

	var result int64 = 0
	pq.lock.Lock()
	for {
		value := f(ts)
		if value == 0 {
			break
		}
		result += value
	}
	pq.lock.Unlock()

	return common.NewIntResponse(result)
}
Пример #2
0
// Returns current server unix time stamp in milliseconds.
func tsHandler(tokens []string) iface.IResponse {
	if len(tokens) > 0 {
		return common.ERR_CMD_WITH_NO_PARAMS
	}
	return common.NewIntResponse(common.Uts())
}