Skip to content

Commit

Permalink
rebase onto unstable, format code
Browse files Browse the repository at this point in the history
  • Loading branch information
lqxhub committed Sep 22, 2023
1 parent 5fb9f2e commit d7f9fc1
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 45 deletions.
2 changes: 1 addition & 1 deletion include/pika_client_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class PikaClientConn : public net::RedisConn {
bool IsPubSub() { return is_pubsub_; }
void SetIsPubSub(bool is_pubsub) { is_pubsub_ = is_pubsub; }
void SetCurrentTable(const std::string& db_name) { current_db_ = db_name; }
const std::string& GetCurrentTable() override{ return current_db_; }
const std::string& GetCurrentTable() override { return current_db_; }
void SetWriteCompleteCallback(WriteCompleteCallback cb) { write_completed_cb_ = std::move(cb); }

void DoAuth(const std::shared_ptr<User>& user);
Expand Down
18 changes: 8 additions & 10 deletions include/pika_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ enum CmdFlagsMask {
};

enum CmdFlags {
kCmdFlagsRead = 1, // default rw
kCmdFlagsRead = 1, // default rw
kCmdFlagsWrite = (1 << 1),
kCmdFlagsAdmin = (1 << 2), // default type
kCmdFlagsKv = (1 << 3),
Expand All @@ -251,13 +251,13 @@ enum CmdFlags {
kCmdFlagsHyperLogLog = (1 << 9),
kCmdFlagsGeo = (1 << 10),
kCmdFlagsPubSub = (1 << 11),
kCmdFlagsNoLocal = 0, // default nolocal
kCmdFlagsNoLocal = 0, // default nolocal
kCmdFlagsLocal = (1 << 12),
kCmdFlagsNoSuspend = 0, // default nosuspend
kCmdFlagsNoSuspend = 0, // default nosuspend
kCmdFlagsSuspend = (1 << 13),
kCmdFlagsNoPrior = 0, // default noprior
kCmdFlagsNoPrior = 0, // default noprior
kCmdFlagsPrior = 128,
kCmdFlagsNoAdminRequire = 0, // default no need admin
kCmdFlagsNoAdminRequire = 0, // default no need admin
kCmdFlagsAdminRequire = (1 << 14),
kCmdFlagsDoNotSpecifySlot = 0, // default do not specify slot
kCmdFlagsSingleSlot = (1 << 15),
Expand All @@ -269,7 +269,7 @@ enum CmdFlags {
void inline RedisAppendContent(std::string& str, const std::string& value);
void inline RedisAppendLen(std::string& str, int64_t ori, const std::string& prefix);
void inline RedisAppendLenUint64(std::string& str, uint64_t ori, const std::string& prefix) {
RedisAppendLen(str, static_cast<int64_t>(ori), prefix);
RedisAppendLen(str, static_cast<int64_t>(ori), prefix);
}

const std::string kNewLine = "\r\n";
Expand Down Expand Up @@ -431,9 +431,9 @@ class CmdRes {
struct UnblockTaskArgs {
std::string key;
std::shared_ptr<Slot> slot;
net::DispatchThread* dispatchThread{ nullptr };
net::DispatchThread* dispatchThread{nullptr};
UnblockTaskArgs(std::string key_, std::shared_ptr<Slot> slot_, net::DispatchThread* dispatchThread_)
: key(std::move(key_)), slot(slot_), dispatchThread(dispatchThread_) {}
: key(std::move(key_)), slot(std::move(slot_)), dispatchThread(dispatchThread_) {}
};

class Cmd : public std::enable_shared_from_this<Cmd> {
Expand Down Expand Up @@ -468,8 +468,6 @@ class Cmd : public std::enable_shared_from_this<Cmd> {
};
CommandStatistics state;
Cmd(std::string name, int arity, uint16_t flag, uint32_t aclCategory = 0);
// Cmd(std::string name, int arity, uint16_t flag);
Cmd(std::string name, int arity, uint16_t flag) : name_(std::move(name)), arity_(arity), flag_(flag) {}
virtual ~Cmd() = default;

virtual std::vector<std::string> current_key() const;
Expand Down
63 changes: 31 additions & 32 deletions include/pika_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,18 @@ class PikaConf : public pstd::BaseConf {
std::shared_lock l(rwlock_);
return bgsave_prefix_;
}
// std::string userpass() {
// std::shared_lock l(rwlock_);
// return userpass_;
// }
// std::string suser_blacklist() {
// std::shared_lock l(rwlock_);
// return pstd::StringConcat(user_blacklist_, COMMA);
// }
// const std::vector<std::string>& vuser_blacklist() {
// std::shared_lock l(rwlock_);
// return user_blacklist_;
// }
// std::string userpass() {
// std::shared_lock l(rwlock_);
// return userpass_;
// }
// std::string suser_blacklist() {
// std::shared_lock l(rwlock_);
// return pstd::StringConcat(user_blacklist_, COMMA);
// }
// const std::vector<std::string>& vuser_blacklist() {
// std::shared_lock l(rwlock_);
// return user_blacklist_;
// }
bool classic_mode() { return classic_mode_.load(); }
int databases() {
std::shared_lock l(rwlock_);
Expand Down Expand Up @@ -446,19 +446,19 @@ class PikaConf : public pstd::BaseConf {
TryPushDiffCommands("masterauth", value);
masterauth_ = value;
}
// void SetUserPass(const std::string& value) {
// std::lock_guard l(rwlock_);
// TryPushDiffCommands("userpass", value);
// userpass_ = value;
// }
// void SetUserBlackList(const std::string& value) {
// std::lock_guard l(rwlock_);
// TryPushDiffCommands("userblacklist", value);
// pstd::StringSplit(value, COMMA, user_blacklist_);
// for (auto& item : user_blacklist_) {
// pstd::StringToLower(item);
// }
// }
// void SetUserPass(const std::string& value) {
// std::lock_guard l(rwlock_);
// TryPushDiffCommands("userpass", value);
// userpass_ = value;
// }
// void SetUserBlackList(const std::string& value) {
// std::lock_guard l(rwlock_);
// TryPushDiffCommands("userblacklist", value);
// pstd::StringSplit(value, COMMA, user_blacklist_);
// for (auto& item : user_blacklist_) {
// pstd::StringToLower(item);
// }
// }
void SetSlotMigrate(const std::string& value) {
std::lock_guard l(rwlock_);
slotmigrate_ = (value == "yes") ? true : false;
Expand Down Expand Up @@ -581,9 +581,8 @@ class PikaConf : public pstd::BaseConf {
max_rsync_parallel_num_ = value;
}

pstd::Status DBSlotsSanityCheck(const std::string& db_name, const std::set<uint32_t>& slot_ids,
bool is_add);
// pstd::Status DBSlotsSanityCheck(const std::string& db_name, const std::set<uint32_t>& slot_ids, bool is_add);
pstd::Status DBSlotsSanityCheck(const std::string& db_name, const std::set<uint32_t>& slot_ids, bool is_add);
// pstd::Status DBSlotsSanityCheck(const std::string& db_name, const std::set<uint32_t>& slot_ids, bool is_add);
pstd::Status AddDBSlots(const std::string& db_name, const std::set<uint32_t>& slot_ids);
pstd::Status RemoveDBSlots(const std::string& db_name, const std::set<uint32_t>& slot_ids);
pstd::Status AddDB(const std::string& db_name, uint32_t slot_num);
Expand Down Expand Up @@ -612,8 +611,8 @@ class PikaConf : public pstd::BaseConf {
int db_sync_speed_ = 0;
std::string compact_cron_;
std::string compact_interval_;
int64_t resume_check_interval_ = 60; // seconds
int64_t least_free_disk_to_resume_ = 268435456; // 256 MB
int64_t resume_check_interval_ = 60; // seconds
int64_t least_free_disk_to_resume_ = 268435456; // 256 MB
double min_check_resume_ratio_ = 0.7;
int64_t write_buffer_size_ = 0;
int64_t arena_block_size_ = 0;
Expand All @@ -630,8 +629,8 @@ class PikaConf : public pstd::BaseConf {
std::string replication_id_;
std::string requirepass_;
std::string masterauth_;
// std::string userpass_;
// std::vector<std::string> user_blacklist_;
// std::string userpass_;
// std::vector<std::string> user_blacklist_;
std::atomic<bool> classic_mode_;
int databases_ = 0;
int default_slot_num_ = 0;
Expand Down
3 changes: 2 additions & 1 deletion include/pika_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class LLenCmd : public Cmd {

class BlockingBaseCmd : public Cmd {
public:
BlockingBaseCmd(const std::string& name, int arity, uint16_t flag) : Cmd(name, arity, flag) {}
BlockingBaseCmd(const std::string& name, int arity, uint16_t flag)
: Cmd(name, arity, flag, static_cast<uint32_t>(AclCategory::LIST)) {}

//blpop/brpop used start
struct WriteBinlogOfPopArgs{
Expand Down
3 changes: 2 additions & 1 deletion src/pika_acl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.

#include <fmt/format.h>

#include "include/pika_acl.h"
#include "fmt/format.h"
#include "include/pika_client_conn.h"
#include "include/pika_cmd_table_manager.h"

Expand Down

0 comments on commit d7f9fc1

Please sign in to comment.