Constant Field Values

Contents

cn.sliew.*

  • cn.sliew.carp.framework.queue.kekio.Queue
    Modifier and Type
    Constant Field
    Value
    public static final int
    5
  • cn.sliew.carp.framework.queue.kekio.redis.AbstractRedisQueue<CLIENT extends redis.clients.jedis.commands.JedisCommands>
    Modifier and Type
    Constant Field
    Value
    protected static final String
    "local java_scientific = function(x)\n return string.format(\"%.12E\", x):gsub(\"\\+\", \"\")\nend\n\n-- get the message, move the fingerprint to the unacked queue and return\nlocal message = redis.call(\"HGET\", messagesKey, fingerprint)\n\n-- check for an ack timeout override on the message\nlocal unackScore = unackDefaultScore\nif type(message) == \"string\" and message ~= nil then\n local ackTimeoutOverride = tonumber(cjson.decode(message)[\"ackTimeoutMs\"])\n if ackTimeoutOverride ~= nil and unackBaseScore ~= nil then\n unackScore = unackBaseScore + ackTimeoutOverride\n end\nend\n\nunackScore = java_scientific(unackScore)\n\nredis.call(\"ZREM\", queueKey, fingerprint)\nredis.call(\"ZADD\", unackKey, unackScore, fingerprint)\n"
    protected static final String
    "local queueKey = KEYS[1]\nlocal unackKey = KEYS[2]\nlocal lockKey = KEYS[3]\nlocal messagesKey = KEYS[4]\nlocal maxScore = ARGV[1]\nlocal peekFingerprintCount = ARGV[2]\nlocal lockTtlSeconds = ARGV[3]\nlocal unackDefaultScore = ARGV[4]\nlocal unackBaseScore = ARGV[5]\n\nlocal not_empty = function(x)\n return (type(x) == \"table\") and (not x.err) and (#x ~= 0)\nend\n\nlocal acquire_lock = function(fingerprints, locksKey, lockTtlSeconds)\n if not_empty(fingerprints) then\n local i=1\n while (i <= #fingerprints) do\n redis.call(\"ECHO\", \"attempting lock on \" .. fingerprints[i])\n if redis.call(\"SET\", locksKey .. \":\" .. fingerprints[i], \"\\uD83D\\uDD12\", \"EX\", lockTtlSeconds, \"NX\") then\n redis.call(\"ECHO\", \"acquired lock on \" .. fingerprints[i])\n return fingerprints[i], fingerprints[i+1]\n end\n i=i+2\n end\n end\n return nil, nil\nend\n\n-- acquire a lock on a fingerprint\nlocal fingerprints = redis.call(\"ZRANGEBYSCORE\", queueKey, 0.0, maxScore, \"WITHSCORES\", \"LIMIT\", 0, peekFingerprintCount)\nlocal fingerprint, fingerprintScore = acquire_lock(fingerprints, lockKey, lockTtlSeconds)\n\n-- no lock could be acquired\nif fingerprint == nil then\n if #fingerprints == 0 then\n return \"NoReadyMessages\"\n end\n return \"AcquireLockFailed\"\nend\n\nlocal java_scientific = function(x)\n return string.format(\"%.12E\", x):gsub(\"\\+\", \"\")\nend\n\n-- get the message, move the fingerprint to the unacked queue and return\nlocal message = redis.call(\"HGET\", messagesKey, fingerprint)\n\n-- check for an ack timeout override on the message\nlocal unackScore = unackDefaultScore\nif type(message) == \"string\" and message ~= nil then\n local ackTimeoutOverride = tonumber(cjson.decode(message)[\"ackTimeoutMs\"])\n if ackTimeoutOverride ~= nil and unackBaseScore ~= nil then\n unackScore = unackBaseScore + ackTimeoutOverride\n end\nend\n\nunackScore = java_scientific(unackScore)\n\nredis.call(\"ZREM\", queueKey, fingerprint)\nredis.call(\"ZADD\", unackKey, unackScore, fingerprint)\nreturn {fingerprint, fingerprintScore, message}\n"