Packages
FerricFlow durable workflows and queues with native-protocol storage, Raft durability, and Bitcask persistence.
Current section
Files
Jump to
Current section
Files
native/resp_parser_nif/src/sections/part_03.rs
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum CommandAstKind {
Get,
Set,
Ping0,
Ping1,
Del,
Exists,
Mget,
Mset,
Incr,
Decr,
Incrby,
Decrby,
Incrbyfloat,
Append,
Strlen,
Getset,
Getdel,
Getex,
Setnx,
Setex,
Psetex,
Getrange,
Setrange,
Msetnx,
Expire,
Pexpire,
Expireat,
Pexpireat,
Ttl,
Pttl,
Persist,
Lpush,
Rpush,
Lpop,
Rpop,
Lrange,
Llen,
Lindex,
Lset,
Lrem,
Ltrim,
Linsert,
Lmove,
Lpushx,
Rpushx,
Rpoplpush,
Hset,
Hget,
Hdel,
Hmget,
Hgetall,
Hexists,
Hkeys,
Hvals,
Hlen,
Hincrby,
Hincrbyfloat,
Hsetnx,
Hstrlen,
Hrandfield,
Hscan,
Hexpire,
Httl,
Hpersist,
Hpexpire,
Hpttl,
Hexpiretime,
Hgetdel,
Hgetex,
Hsetex,
Sadd,
Srem,
Smembers,
Sismember,
Smismember,
Scard,
Sinter,
Sunion,
Sdiff,
Sdiffstore,
Sinterstore,
Sunionstore,
Sintercard,
Srandmember,
Spop,
Smove,
Sscan,
Zadd,
Zrem,
Zscore,
Zrank,
Zrevrank,
Zrange,
Zrevrange,
Zcard,
Zincrby,
Zcount,
Zpopmin,
Zpopmax,
Zrandmember,
Zscan,
Zmscore,
Zrangebyscore,
Zrevrangebyscore,
Setbit,
Getbit,
Bitcount,
Bitpos,
Bitop,
Type,
Unlink,
Rename,
Renamenx,
Copy,
Randomkey,
Scan,
Expiretime,
Pexpiretime,
Object,
Wait,
Xadd,
Xlen,
Xrange,
Xrevrange,
Xread,
Xtrim,
Xdel,
Xinfo,
Xgroup,
Xreadgroup,
Xack,
JsonSet,
JsonGet,
JsonDel,
JsonNumincrby,
JsonType,
JsonStrlen,
JsonObjkeys,
JsonObjlen,
JsonArrappend,
JsonArrlen,
JsonToggle,
JsonClear,
JsonMget,
Geoadd,
Geopos,
Geodist,
Geohash,
Geosearch,
Geosearchstore,
Pfadd,
Pfcount,
Pfmerge,
BfReserve,
BfAdd,
BfMadd,
BfExists,
BfMexists,
BfCard,
BfInfo,
CfReserve,
CfAdd,
CfAddnx,
CfDel,
CfExists,
CfMexists,
CfCount,
CfInfo,
CmsInitbydim,
CmsInitbyprob,
CmsIncrby,
CmsQuery,
CmsMerge,
CmsInfo,
TopkReserve,
TopkAdd,
TopkIncrby,
TopkQuery,
TopkList,
TopkCount,
TopkInfo,
TdigestCreate,
TdigestAdd,
TdigestReset,
TdigestQuantile,
TdigestCdf,
TdigestRank,
TdigestRevrank,
TdigestByrank,
TdigestByrevrank,
TdigestTrimmedMean,
TdigestMin,
TdigestMax,
TdigestInfo,
TdigestMerge,
FlowCreate,
FlowCreateMany,
FlowValuePut,
FlowSignal,
FlowSpawnChildren,
FlowGet,
FlowPolicySet,
FlowPolicyGet,
FlowClaimDue,
FlowReclaim,
FlowExtendLease,
FlowComplete,
FlowCompleteMany,
FlowTransition,
FlowTransitionMany,
FlowRetry,
FlowRetryMany,
FlowFail,
FlowFailMany,
FlowCancel,
FlowCancelMany,
FlowRewind,
FlowList,
FlowTerminals,
FlowFailures,
FlowByParent,
FlowByRoot,
FlowByCorrelation,
FlowInfo,
FlowStuck,
FlowHistory,
FlowRetentionCleanup,
Blpop,
Brpop,
Blmove,
Blmpop,
Hello,
Auth,
Acl,
Client,
Sandbox,
Subscribe,
Unsubscribe,
Psubscribe,
Punsubscribe,
Multi,
Exec,
Discard,
Watch,
Unwatch,
Reset,
Quit,
Unknown,
}
fn classify_command_ast(cmd: &[u8], arity: usize) -> CommandAstKind {
match cmd {
b"GET" if arity == 1 => CommandAstKind::Get,
b"SET" if arity == 2 => CommandAstKind::Set,
b"PING" if arity == 0 => CommandAstKind::Ping0,
b"PING" if arity == 1 => CommandAstKind::Ping1,
b"DEL" => CommandAstKind::Del,
b"EXISTS" => CommandAstKind::Exists,
b"MGET" => CommandAstKind::Mget,
b"MSET" => CommandAstKind::Mset,
b"INCR" if arity == 1 => CommandAstKind::Incr,
b"DECR" if arity == 1 => CommandAstKind::Decr,
b"INCRBY" if arity == 2 => CommandAstKind::Incrby,
b"DECRBY" if arity == 2 => CommandAstKind::Decrby,
b"INCRBYFLOAT" if arity == 2 => CommandAstKind::Incrbyfloat,
b"APPEND" if arity == 2 => CommandAstKind::Append,
b"STRLEN" if arity == 1 => CommandAstKind::Strlen,
b"GETSET" if arity == 2 => CommandAstKind::Getset,
b"GETDEL" if arity == 1 => CommandAstKind::Getdel,
b"GETEX" if arity == 1 || arity == 2 || arity == 3 => CommandAstKind::Getex,
b"SETNX" if arity == 2 => CommandAstKind::Setnx,
b"SETEX" if arity == 3 => CommandAstKind::Setex,
b"PSETEX" if arity == 3 => CommandAstKind::Psetex,
b"GETRANGE" if arity == 3 => CommandAstKind::Getrange,
b"SETRANGE" if arity == 3 => CommandAstKind::Setrange,
b"MSETNX" => CommandAstKind::Msetnx,
b"EXPIRE" if arity == 2 || arity == 3 => CommandAstKind::Expire,
b"PEXPIRE" if arity == 2 || arity == 3 => CommandAstKind::Pexpire,
b"EXPIREAT" if arity == 2 || arity == 3 => CommandAstKind::Expireat,
b"PEXPIREAT" if arity == 2 || arity == 3 => CommandAstKind::Pexpireat,
b"TTL" if arity == 1 => CommandAstKind::Ttl,
b"PTTL" if arity == 1 => CommandAstKind::Pttl,
b"PERSIST" if arity == 1 => CommandAstKind::Persist,
b"LPUSH" if arity >= 2 => CommandAstKind::Lpush,
b"RPUSH" if arity >= 2 => CommandAstKind::Rpush,
b"LPOP" if arity == 1 || arity == 2 => CommandAstKind::Lpop,
b"RPOP" if arity == 1 || arity == 2 => CommandAstKind::Rpop,
b"LRANGE" if arity == 3 => CommandAstKind::Lrange,
b"LLEN" if arity == 1 => CommandAstKind::Llen,
b"LINDEX" if arity == 2 => CommandAstKind::Lindex,
b"LSET" if arity == 3 => CommandAstKind::Lset,
b"LREM" if arity == 3 => CommandAstKind::Lrem,
b"LTRIM" if arity == 3 => CommandAstKind::Ltrim,
b"LINSERT" if arity == 4 => CommandAstKind::Linsert,
b"LMOVE" if arity == 4 => CommandAstKind::Lmove,
b"LPUSHX" if arity >= 2 => CommandAstKind::Lpushx,
b"RPUSHX" if arity >= 2 => CommandAstKind::Rpushx,
b"RPOPLPUSH" if arity == 2 => CommandAstKind::Rpoplpush,
b"HSET" if arity >= 3 => CommandAstKind::Hset,
b"HGET" if arity == 2 => CommandAstKind::Hget,
b"HDEL" if arity >= 2 => CommandAstKind::Hdel,
b"HMGET" if arity >= 2 => CommandAstKind::Hmget,
b"HGETALL" if arity == 1 => CommandAstKind::Hgetall,
b"HEXISTS" if arity == 2 => CommandAstKind::Hexists,
b"HKEYS" if arity == 1 => CommandAstKind::Hkeys,
b"HVALS" if arity == 1 => CommandAstKind::Hvals,
b"HLEN" if arity == 1 => CommandAstKind::Hlen,
b"HINCRBY" if arity == 3 => CommandAstKind::Hincrby,
b"HINCRBYFLOAT" if arity == 3 => CommandAstKind::Hincrbyfloat,
b"HSETNX" if arity == 3 => CommandAstKind::Hsetnx,
b"HSTRLEN" if arity == 2 => CommandAstKind::Hstrlen,
b"HRANDFIELD" if arity == 1 || arity == 2 || arity == 3 => CommandAstKind::Hrandfield,
b"HSCAN" if arity >= 2 => CommandAstKind::Hscan,
b"HEXPIRE" if arity >= 4 => CommandAstKind::Hexpire,
b"HTTL" if arity >= 3 => CommandAstKind::Httl,
b"HPERSIST" if arity >= 3 => CommandAstKind::Hpersist,
b"HPEXPIRE" if arity >= 4 => CommandAstKind::Hpexpire,
b"HPTTL" if arity >= 3 => CommandAstKind::Hpttl,
b"HEXPIRETIME" if arity >= 3 => CommandAstKind::Hexpiretime,
b"HGETDEL" if arity >= 3 => CommandAstKind::Hgetdel,
b"HGETEX" if arity >= 4 => CommandAstKind::Hgetex,
b"HSETEX" if arity >= 4 => CommandAstKind::Hsetex,
b"SADD" if arity >= 2 => CommandAstKind::Sadd,
b"SREM" if arity >= 2 => CommandAstKind::Srem,
b"SMEMBERS" if arity == 1 => CommandAstKind::Smembers,
b"SISMEMBER" if arity == 2 => CommandAstKind::Sismember,
b"SMISMEMBER" if arity >= 2 => CommandAstKind::Smismember,
b"SCARD" if arity == 1 => CommandAstKind::Scard,
b"SINTER" if arity >= 1 => CommandAstKind::Sinter,
b"SUNION" if arity >= 1 => CommandAstKind::Sunion,
b"SDIFF" if arity >= 1 => CommandAstKind::Sdiff,
b"SDIFFSTORE" if arity >= 2 => CommandAstKind::Sdiffstore,
b"SINTERSTORE" if arity >= 2 => CommandAstKind::Sinterstore,
b"SUNIONSTORE" if arity >= 2 => CommandAstKind::Sunionstore,
b"SINTERCARD" if arity >= 2 => CommandAstKind::Sintercard,
b"SRANDMEMBER" if arity == 1 || arity == 2 => CommandAstKind::Srandmember,
b"SPOP" if arity == 1 || arity == 2 => CommandAstKind::Spop,
b"SMOVE" if arity == 3 => CommandAstKind::Smove,
b"SSCAN" if arity >= 2 => CommandAstKind::Sscan,
b"ZADD" if arity >= 3 => CommandAstKind::Zadd,
b"ZREM" if arity >= 2 => CommandAstKind::Zrem,
b"ZSCORE" if arity == 2 => CommandAstKind::Zscore,
b"ZRANK" if arity == 2 => CommandAstKind::Zrank,
b"ZREVRANK" if arity == 2 => CommandAstKind::Zrevrank,
b"ZRANGE" if arity == 3 || arity == 4 => CommandAstKind::Zrange,
b"ZREVRANGE" if arity == 3 || arity == 4 => CommandAstKind::Zrevrange,
b"ZCARD" if arity == 1 => CommandAstKind::Zcard,
b"ZINCRBY" if arity == 3 => CommandAstKind::Zincrby,
b"ZCOUNT" if arity == 3 => CommandAstKind::Zcount,
b"ZPOPMIN" if arity == 1 || arity == 2 => CommandAstKind::Zpopmin,
b"ZPOPMAX" if arity == 1 || arity == 2 => CommandAstKind::Zpopmax,
b"ZRANDMEMBER" if arity == 1 || arity == 2 || arity == 3 => CommandAstKind::Zrandmember,
b"ZSCAN" if arity >= 2 => CommandAstKind::Zscan,
b"ZMSCORE" if arity >= 2 => CommandAstKind::Zmscore,
b"ZRANGEBYSCORE" if arity >= 3 => CommandAstKind::Zrangebyscore,
b"ZREVRANGEBYSCORE" if arity >= 3 => CommandAstKind::Zrevrangebyscore,
b"SETBIT" if arity == 3 => CommandAstKind::Setbit,
b"GETBIT" if arity == 2 => CommandAstKind::Getbit,
b"BITCOUNT" if arity == 1 || arity == 3 || arity == 4 => CommandAstKind::Bitcount,
b"BITPOS" if (2..=5).contains(&arity) => CommandAstKind::Bitpos,
b"BITOP" if arity >= 3 => CommandAstKind::Bitop,
b"TYPE" if arity == 1 => CommandAstKind::Type,
b"UNLINK" if arity >= 1 => CommandAstKind::Unlink,
b"RENAME" if arity == 2 => CommandAstKind::Rename,
b"RENAMENX" if arity == 2 => CommandAstKind::Renamenx,
b"COPY" if arity >= 2 => CommandAstKind::Copy,
b"RANDOMKEY" if arity == 0 => CommandAstKind::Randomkey,
b"SCAN" if arity >= 1 => CommandAstKind::Scan,
b"EXPIRETIME" if arity == 1 => CommandAstKind::Expiretime,
b"PEXPIRETIME" if arity == 1 => CommandAstKind::Pexpiretime,
b"OBJECT" if arity >= 1 => CommandAstKind::Object,
b"WAIT" if arity == 2 => CommandAstKind::Wait,
b"XADD" if arity >= 4 => CommandAstKind::Xadd,
b"XLEN" if arity == 1 => CommandAstKind::Xlen,
b"XRANGE" if arity >= 3 => CommandAstKind::Xrange,
b"XREVRANGE" if arity >= 3 => CommandAstKind::Xrevrange,
b"XREAD" if arity >= 3 => CommandAstKind::Xread,
b"XTRIM" if arity >= 2 => CommandAstKind::Xtrim,
b"XDEL" if arity >= 2 => CommandAstKind::Xdel,
b"XINFO" if arity >= 2 => CommandAstKind::Xinfo,
b"XGROUP" if arity >= 4 => CommandAstKind::Xgroup,
b"XREADGROUP" if arity >= 6 => CommandAstKind::Xreadgroup,
b"XACK" if arity >= 3 => CommandAstKind::Xack,
b"JSON.SET" => CommandAstKind::JsonSet,
b"JSON.GET" => CommandAstKind::JsonGet,
b"JSON.DEL" => CommandAstKind::JsonDel,
b"JSON.NUMINCRBY" => CommandAstKind::JsonNumincrby,
b"JSON.TYPE" => CommandAstKind::JsonType,
b"JSON.STRLEN" => CommandAstKind::JsonStrlen,
b"JSON.OBJKEYS" => CommandAstKind::JsonObjkeys,
b"JSON.OBJLEN" => CommandAstKind::JsonObjlen,
b"JSON.ARRAPPEND" => CommandAstKind::JsonArrappend,
b"JSON.ARRLEN" => CommandAstKind::JsonArrlen,
b"JSON.TOGGLE" => CommandAstKind::JsonToggle,
b"JSON.CLEAR" => CommandAstKind::JsonClear,
b"JSON.MGET" => CommandAstKind::JsonMget,
b"GEOADD" => CommandAstKind::Geoadd,
b"GEOPOS" => CommandAstKind::Geopos,
b"GEODIST" => CommandAstKind::Geodist,
b"GEOHASH" => CommandAstKind::Geohash,
b"GEOSEARCH" => CommandAstKind::Geosearch,
b"GEOSEARCHSTORE" => CommandAstKind::Geosearchstore,
b"PFADD" => CommandAstKind::Pfadd,
b"PFCOUNT" => CommandAstKind::Pfcount,
b"PFMERGE" => CommandAstKind::Pfmerge,
b"BF.RESERVE" => CommandAstKind::BfReserve,
b"BF.ADD" => CommandAstKind::BfAdd,
b"BF.MADD" => CommandAstKind::BfMadd,
b"BF.EXISTS" => CommandAstKind::BfExists,
b"BF.MEXISTS" => CommandAstKind::BfMexists,
b"BF.CARD" => CommandAstKind::BfCard,
b"BF.INFO" => CommandAstKind::BfInfo,
b"CF.RESERVE" => CommandAstKind::CfReserve,
b"CF.ADD" => CommandAstKind::CfAdd,
b"CF.ADDNX" => CommandAstKind::CfAddnx,
b"CF.DEL" => CommandAstKind::CfDel,
b"CF.EXISTS" => CommandAstKind::CfExists,
b"CF.MEXISTS" => CommandAstKind::CfMexists,
b"CF.COUNT" => CommandAstKind::CfCount,
b"CF.INFO" => CommandAstKind::CfInfo,
b"CMS.INITBYDIM" => CommandAstKind::CmsInitbydim,
b"CMS.INITBYPROB" => CommandAstKind::CmsInitbyprob,
b"CMS.INCRBY" => CommandAstKind::CmsIncrby,
b"CMS.QUERY" => CommandAstKind::CmsQuery,
b"CMS.MERGE" => CommandAstKind::CmsMerge,
b"CMS.INFO" => CommandAstKind::CmsInfo,
b"TOPK.RESERVE" => CommandAstKind::TopkReserve,
b"TOPK.ADD" => CommandAstKind::TopkAdd,
b"TOPK.INCRBY" => CommandAstKind::TopkIncrby,
b"TOPK.QUERY" => CommandAstKind::TopkQuery,
b"TOPK.LIST" => CommandAstKind::TopkList,
b"TOPK.COUNT" => CommandAstKind::TopkCount,
b"TOPK.INFO" => CommandAstKind::TopkInfo,
b"TDIGEST.CREATE" => CommandAstKind::TdigestCreate,
b"TDIGEST.ADD" => CommandAstKind::TdigestAdd,
b"TDIGEST.RESET" => CommandAstKind::TdigestReset,
b"TDIGEST.QUANTILE" => CommandAstKind::TdigestQuantile,
b"TDIGEST.CDF" => CommandAstKind::TdigestCdf,
b"TDIGEST.RANK" => CommandAstKind::TdigestRank,
b"TDIGEST.REVRANK" => CommandAstKind::TdigestRevrank,
b"TDIGEST.BYRANK" => CommandAstKind::TdigestByrank,
b"TDIGEST.BYREVRANK" => CommandAstKind::TdigestByrevrank,
b"TDIGEST.TRIMMED_MEAN" => CommandAstKind::TdigestTrimmedMean,
b"TDIGEST.MIN" => CommandAstKind::TdigestMin,
b"TDIGEST.MAX" => CommandAstKind::TdigestMax,
b"TDIGEST.INFO" => CommandAstKind::TdigestInfo,
b"TDIGEST.MERGE" => CommandAstKind::TdigestMerge,
b"FLOW.CREATE" => CommandAstKind::FlowCreate,
b"FLOW.CREATE_MANY" => CommandAstKind::FlowCreateMany,
b"FLOW.VALUE.PUT" => CommandAstKind::FlowValuePut,
b"FLOW.SIGNAL" => CommandAstKind::FlowSignal,
b"FLOW.SPAWN_CHILDREN" => CommandAstKind::FlowSpawnChildren,
b"FLOW.GET" => CommandAstKind::FlowGet,
b"FLOW.POLICY.SET" => CommandAstKind::FlowPolicySet,
b"FLOW.POLICY.GET" => CommandAstKind::FlowPolicyGet,
b"FLOW.CLAIM_DUE" => CommandAstKind::FlowClaimDue,
b"FLOW.RECLAIM" => CommandAstKind::FlowReclaim,
b"FLOW.EXTEND_LEASE" => CommandAstKind::FlowExtendLease,
b"FLOW.COMPLETE" => CommandAstKind::FlowComplete,
b"FLOW.COMPLETE_MANY" => CommandAstKind::FlowCompleteMany,
b"FLOW.TRANSITION" => CommandAstKind::FlowTransition,
b"FLOW.TRANSITION_MANY" => CommandAstKind::FlowTransitionMany,
b"FLOW.RETRY" => CommandAstKind::FlowRetry,
b"FLOW.RETRY_MANY" => CommandAstKind::FlowRetryMany,
b"FLOW.FAIL" => CommandAstKind::FlowFail,
b"FLOW.FAIL_MANY" => CommandAstKind::FlowFailMany,
b"FLOW.CANCEL" => CommandAstKind::FlowCancel,
b"FLOW.CANCEL_MANY" => CommandAstKind::FlowCancelMany,
b"FLOW.REWIND" => CommandAstKind::FlowRewind,
b"FLOW.LIST" => CommandAstKind::FlowList,
b"FLOW.TERMINALS" => CommandAstKind::FlowTerminals,
b"FLOW.FAILURES" => CommandAstKind::FlowFailures,
b"FLOW.BY_PARENT" => CommandAstKind::FlowByParent,
b"FLOW.BY_ROOT" => CommandAstKind::FlowByRoot,
b"FLOW.BY_CORRELATION" => CommandAstKind::FlowByCorrelation,
b"FLOW.INFO" => CommandAstKind::FlowInfo,
b"FLOW.STUCK" => CommandAstKind::FlowStuck,
b"FLOW.HISTORY" => CommandAstKind::FlowHistory,
b"FLOW.RETENTION_CLEANUP" => CommandAstKind::FlowRetentionCleanup,
b"BLPOP" => CommandAstKind::Blpop,
b"BRPOP" => CommandAstKind::Brpop,
b"BLMOVE" => CommandAstKind::Blmove,
b"BLMPOP" => CommandAstKind::Blmpop,
b"HELLO" => CommandAstKind::Hello,
b"AUTH" => CommandAstKind::Auth,
b"ACL" => CommandAstKind::Acl,
b"CLIENT" => CommandAstKind::Client,
b"SANDBOX" => CommandAstKind::Sandbox,
b"SUBSCRIBE" => CommandAstKind::Subscribe,
b"UNSUBSCRIBE" => CommandAstKind::Unsubscribe,
b"PSUBSCRIBE" => CommandAstKind::Psubscribe,
b"PUNSUBSCRIBE" => CommandAstKind::Punsubscribe,
b"MULTI" => CommandAstKind::Multi,
b"EXEC" => CommandAstKind::Exec,
b"DISCARD" => CommandAstKind::Discard,
b"WATCH" => CommandAstKind::Watch,
b"UNWATCH" => CommandAstKind::Unwatch,
b"RESET" => CommandAstKind::Reset,
b"QUIT" => CommandAstKind::Quit,
_ => CommandAstKind::Unknown,
}
}