// Copyright 2021, Roman Gershman. All rights reserved. // See LICENSE for licensing terms. // #pragma once #include #include "server/common_types.h" #include "server/reply_builder.h" namespace dfly { class Connection; class EngineShardSet; struct StoredCmd { const CommandId* descr; std::vector cmd; StoredCmd(const CommandId* d = nullptr) : descr(d) { } }; struct ConnectionState { DbIndex db_index = 0; enum ExecState { EXEC_INACTIVE, EXEC_COLLECT, EXEC_ERROR }; ExecState exec_state = EXEC_INACTIVE; std::vector exec_body; enum Mask : uint32_t { ASYNC_DISPATCH = 1, // whether a command is handled via async dispatch. CONN_CLOSING = 2, // could be because of unrecoverable error or planned action. // Whether this connection belongs to replica, i.e. a dragonfly slave is connected to this // host (master) via this connection to sync from it. REPL_CONNECTION = 4, REQ_AUTH = 8, AUTHENTICATED = 0x10, }; uint32_t mask = 0; // A bitmask of Mask values. enum MCGetMask { FETCH_CAS_VER = 1, }; // used for memcache set/get commands. // For set op - it's the flag value we are storing along with the value. // For get op - we use it as a mask of MCGetMask values. uint32_t memcache_flag = 0; bool IsClosing() const { return mask & CONN_CLOSING; } bool IsRunViaDispatch() const { return mask & ASYNC_DISPATCH; } // Lua-script related data. struct Script { bool is_write = true; absl::flat_hash_set keys; }; std::optional