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

Add contrib/mariadbclient #469

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

hfcrwx
Copy link
Contributor

@hfcrwx hfcrwx commented May 29, 2020

MariaDB Async Client
Using Non-blocking API

Reference:
https://mariadb.com/kb/en/using-the-non-blocking-library/
https://github.com/MariaDB/server/blob/5.5/client/async_example.c
https://github.com/MariaDB/server/blob/5.5/tests/async_queries.c
https://mariadb.com/kb/en/non-blocking-api-reference/

Build:
centos7-x86_64:
yum install mariadb-devel mariadb-libs
ubuntu14.04-x86_64:
apt-get install libmariadbclient-dev
ln -sf libmariadbclient.so libmysqlclient.so

@chenshuo
Copy link
Owner

Please fix travis-ci first, put apt-get install in .travis.yml.

Copy link
Owner

@chenshuo chenshuo left a comment

Choose a reason for hiding this comment

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

I haven't read the contrib/mariadhclient/ part, will do it later.

Channel(EventLoop* loop, int fd);
typedef std::function<void(int, Timestamp)> EventsCallback;

Channel(EventLoop* loop, int fd, bool classify = true);
Copy link
Owner

Choose a reason for hiding this comment

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

I suggest not to introduce the new classify parameter. Instead, if EventsCallback is provided, it intercepts all events.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean change
channel_->setEventsCallback(std::bind(&MariaDBClient::stateMachineHandler, this, kRealConnectCont, _1, 2));
to
channel
->setReadCallback(std::bind(&MariaDBClient::stateMachineHandler, this, kRealConnectCont, _1, 2));
channel
->setWriteCallback(std::bind(&MariaDBClient::stateMachineHandler, this, kRealConnectCont, _1, _2));
?

muduo/net/Channel.h Outdated Show resolved Hide resolved
@@ -67,6 +72,8 @@ class Channel : noncopyable
bool isWriting() const { return events_ & kWriteEvent; }
bool isReading() const { return events_ & kReadEvent; }

void enableEvents(int events__) { events_ = events__; update(); }
Copy link
Owner

Choose a reason for hiding this comment

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

Parameter events__ -> events.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

on centos7-x86_64:
if events__ -> events
错误:‘events’的声明隐藏了‘this’的一个成员 [-Werror=shadow]
events shadows int events()

ref:
Channel::Channel(EventLoop* loop, int fd__, bool classify)

@hfcrwx
Copy link
Contributor Author

hfcrwx commented Jun 25, 2020

Update:

  1. zero copy MYSQL_RES:
    mysql_use_result, mysql_fetch_row_* -> mysql_store_result_*
    use new callback function: std::function<void(MariaDBClient*, MYSQL_RES*)>

  2. change MariaDBClient to a single-threaded version (as Hiredis, Curl)

  3. refactors

Test successfully with MariaDB-Server/MySQL-Server

ref:
https://mariadb.com/kb/en/non-blocking-api-reference/
https://dev.mysql.com/doc/refman/5.7/en/mysql-store-result.html

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.

2 participants