1

我正在尝试使用 tarantool fifttl queue 在其中存储一些延迟任务。

我必须使用以下界面来存储任务:

queue.tube.tube_name:put({ some_key, 'some_data' }, { delay = 80 })

如何在不更改任务状态的情况下检索当前任务延迟?

4

1 回答 1

1

简而言之:使用 Queue API 无法做到这一点。

长答案:这个队列的基本规则之一是:“没有人知道任务,如果它没有被接受”,所以它违反了这个规则。

Dirty hack:您可以从 Tarantool 空间获取此信息:

local states = require('queue.abstract.state')

local state, time = *queue-instance*.space:get{*TASK_ID*}:unpack(2, 3)}

if state == states.DELAYED then
    -- task is delayed, so time in `time` is the right time
end 
于 2016-04-19T12:46:26.243 回答