-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Pub/Sub #207
Support Pub/Sub #207
Conversation
include/pika_client_conn.h
Outdated
@@ -21,10 +21,17 @@ class PikaClientConn: public pink::RedisConn { | |||
void* worker_specific_data); | |||
virtual ~PikaClientConn() {} | |||
virtual int DealMessage(); | |||
bool PubSub() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
用is_pubsub()?
include/pika_client_conn.h
Outdated
bool PubSub() { | ||
return is_pubsub_; | ||
} | ||
void SetPubSub(bool is_pubsub) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set_is_pubsub()?
include/pika_server.h
Outdated
std::vector<std::pair<std::string, int>>* result); | ||
|
||
void PubSubChannels(const std::string& pattern, | ||
std::vector<std::string >* result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥有个空格?
src/pika_client_conn.cc
Outdated
auth_stat_.Init(); | ||
} | ||
|
||
std::string ConstructPubSubResp(const std::string& cmd, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pink里不是有这个函数了吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pink里是redis conn 里构造Publish的响应消息
这里是pika conn构造sub unsub的响应消息
publish的响应消息由pink发送
sub unsub的响应消息由pika这层发送
src/pika_client_conn.cc
Outdated
std::vector<std::pair<std::string, int>> result; | ||
g_pika_server->Subscribe(conn, channels, false, &result); | ||
this->SetPubSub(true); | ||
return ConstructPubSubResp(kCmdNameSubscribe, result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
要么就去掉pink里的ConstructPubSubResp,都交给pika来构造,按理说pink的pubsub不应该有协议相关的东西
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯 Pubsub没有与协议相关的东西 调用的是redis conn里面的接口构造publish的消息
include/pika_pubsub.h
Outdated
* pubsub | ||
*/ | ||
class PublishCmd : public Cmd { | ||
public: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
统一改成public 一格缩进
src/pika_client_conn.cc
Outdated
const std::vector<std::pair<std::string, int>>& result) { | ||
std::stringstream resp; | ||
if (result.size() == 0) { | ||
resp << "*3\r\n" << "$" << cmd.length() << "\r\n" << cmd << |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改成用 printf 或者 snprintf, 别用iostream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
正在修改
* add pubsub interface * modify client connection flag * bugfix * bugfix * bugfix * add pubsub() * type * bugfix channels name * format * optimize code * bugfix interface * bugfix * bugfix * optimize code * bugfix * bugfix * fix conflict * fix conflict * modify header file
* add pubsub interface * modify client connection flag * bugfix * bugfix * bugfix * add pubsub() * type * bugfix channels name * format * optimize code * bugfix interface * bugfix * bugfix * optimize code * bugfix * bugfix * fix conflict * fix conflict * modify header file
No description provided.