add passwd in redis_pipeline

This commit is contained in:
shuxin   zheng 2021-01-02 20:28:13 +08:00
parent 2481eaa88c
commit 91a9d26c69
2 changed files with 14 additions and 1 deletions

View File

@ -81,6 +81,9 @@ public:
bool start_thread(void);
public:
redis_pipeline_channel& set_passwd(const char* passwd);
protected:
// @override
void* run(void);
@ -88,6 +91,7 @@ protected:
private:
string addr_;
string buf_;
string passwd_;
redis_client* conn_;
BOX<redis_pipeline_message> box_;
std::vector<redis_pipeline_message*> msgs_;

View File

@ -24,13 +24,22 @@ redis_pipeline_channel::~redis_pipeline_channel(void)
delete conn_;
}
redis_pipeline_channel & redis_pipeline_channel::set_passwd(const char *passwd) {
if (passwd && *passwd) {
passwd_ = passwd;
}
return *this;
}
bool redis_pipeline_channel::start_thread(void)
{
if (!((connect_client*) conn_)->open()) {
logger_error("open %s error %s", addr_.c_str(), last_serror());
return false;
}
if (!passwd_.empty()) {
conn_->set_password(passwd_);
}
this->start();
return true;
}