nadis 2.0.1

Redis 基础层:业务键有序分区消费、Stream/Proxy 生命周期、有界微批、幂等管线、锁与 RedisJob
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-- 业务作用:标记 Fanout 终态已成功回填普通根 Run,从此允许按保留期回收桶内证据。
-- KEYS[1] Fanout 根 HASH;KEYS[2] roots/watch ZSET。
-- ARGV[1] fanoutId。
-- 返回:STATE_MISMATCH 或 {OK, reconciledAt}。
-- 安全不变量:只有桶内根已终态才能标记对账;清理脚本会同时复验 reconciledAt 和 expireAt。

local state = redis.call('HGET', KEYS[1], 'state')
if state ~= 'SUCCEEDED' and state ~= 'PARTIAL_FAILED' and state ~= 'FAILED' and state ~= 'CANCELLED' then
    return {'STATE_MISMATCH'}
end
local time = redis.call('TIME')
local now = time[1] * 1000 + math.floor(time[2] / 1000)
redis.call('HSET', KEYS[1], 'reconciledAt', now)
redis.call('ZADD', KEYS[2], redis.call('HGET', KEYS[1], 'expireAt') or now, ARGV[1])
return {'OK', tostring(now)}