Skip to content
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

Merged
merged 20 commits into from Nov 16, 2017
Merged

Support Pub/Sub #207

merged 20 commits into from Nov 16, 2017

Conversation

Leviathan1995
Copy link
Contributor

No description provided.

@@ -21,10 +21,17 @@ class PikaClientConn: public pink::RedisConn {
void* worker_specific_data);
virtual ~PikaClientConn() {}
virtual int DealMessage();
bool PubSub() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用is_pubsub()?

bool PubSub() {
return is_pubsub_;
}
void SetPubSub(bool is_pubsub) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set_is_pubsub()?

std::vector<std::pair<std::string, int>>* result);

void PubSubChannels(const std::string& pattern,
std::vector<std::string >* result);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥有个空格?

auth_stat_.Init();
}

std::string ConstructPubSubResp(const std::string& cmd,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pink里不是有这个函数了吗?

Copy link
Contributor Author

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这层发送

std::vector<std::pair<std::string, int>> result;
g_pika_server->Subscribe(conn, channels, false, &result);
this->SetPubSub(true);
return ConstructPubSubResp(kCmdNameSubscribe, result);
Copy link
Collaborator

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不应该有协议相关的东西

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯 Pubsub没有与协议相关的东西 调用的是redis conn里面的接口构造publish的消息

* pubsub
*/
class PublishCmd : public Cmd {
public:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

统一改成public 一格缩进

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 <<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成用 printf 或者 snprintf, 别用iostream

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

正在修改

@gaodq gaodq mentioned this pull request Nov 15, 2017
@KernelMaker KernelMaker merged commit a76dd54 into OpenAtomFoundation:master Nov 16, 2017
bigdaronlee163 pushed a commit to bigdaronlee163/pika that referenced this pull request Jun 8, 2024
* 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
cheniujh pushed a commit to cheniujh/pika that referenced this pull request Sep 24, 2024
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants