[GitHub] [brpc] wasphin commented on a diff in pull request #2095: Update release steps for TLP

2023-01-23 Thread via GitHub


wasphin commented on code in PR #2095:
URL: https://github.com/apache/brpc/pull/2095#discussion_r1083746456


##
community/release_cn.md:
##
@@ -295,63 +311,62 @@ Do you really want to set this key to ultimate trust? 
(y/N) y
 gpg> save
 ```
 
-然后进行gpg签名检查。
+然后进行 gpg 签名检查。
 ```
-gpg --verify apache-brpc-1.0.0-incubating-src.tar.gz.asc 
apache-brpc-1.0.0-incubating-src.tar.gz
+gpg --verify apache-brpc-1.0.0-src.tar.gz.asc apache-brpc-1.0.0-src.tar.gz
 ```
 
 ## 3. 检查发布内容
 
-### 1. 对比源码包与github上的tag内容差异
+### 1. 对比源码包与 github 上的 tag 内容差异
 
 ```bash
 curl -Lo tag-1.0.0.tar.gz 
https://github.com/apache/brpc/archive/refs/tags/1.0.0.tar.gz
 
 tar xvzf tag-1.0.0.tar.gz
 
-tar xvzf apache-brpc-1.0.0-incubating-src.tar.gz
+tar xvzf apache-brpc-1.0.0-src.tar.gz
 
-diff -r brpc-1.0.0 apache-brpc-1.0.0-incubating-src
+diff -r brpc-1.0.0 apache-brpc-1.0.0-src
 ```
 
 ### 2. 检查源码包的文件内容
 
-- 检查源码包是否包含由于包含不必要文件,致使tarball过于庞大
-- 存在LICENSE和NOTICE文件
-- NOTICE文件中的年份正确
+- 检查源码包是否包含由于包含不必要文件,致使 tarball 过于庞大
+- 存在 LICENSE 和 NOTICE 文件
+- NOTICE 文件中的年份正确
 - 只存在文本文件,不存在二进制文件
-- 所有文件的开头都有ASF许可证
+- 所有文件的开头都有 ASF 许可证
 - 能够正确编译,单元测试可以通过
 - 检查是否有多余文件或文件夹,例如空文件夹等
 - 检查第三方依赖许可证:
   - 第三方依赖的许可证兼容
-  - 所有第三方依赖的许可证都在LICENSE文件中声名
-  - 依赖许可证的完整版全部在license目录
-  - 如果依赖的是Apache许可证并且存在NOTICE文件,那么这些NOTICE文件也需要加入到版本的NOTICE文件中
+  - 所有第三方依赖的许可证都在 LICENSE 文件中声名
+  - 依赖许可证的完整版全部在 license 目录
+  - 如果依赖的是 Apache 许可证并且存在 NOTICE 文件,那么这些 NOTICE 文件也需要加入到版本的 NOTICE 文件中
 
-# 在Apache brpc社区发起投票
+# 在 Apache bRPC 社区发起投票
 
 ## 1. 投票阶段
 
-1. 发起投票邮件到dev@brpc.apache.org。PPMC需要先按文档检查版本的正确性,然后再进行投票。经过至少72小时并统计到3个+1 PPMC 
member票后,即可进入下一阶段。
-2. 宣布投票结果,发起投票结果邮件到dev@brpc.apache.org。
+1. 发起投票邮件到 dev@brpc.apache.org。PPMC 需要先按文档检查版本的正确性,然后再进行投票。经过至少 72 小时并统计到 3 个 
+1 PPMC member 票后,即可进入下一阶段。

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[brpc] branch master updated: Uppdate release steps

2023-01-23 Thread xiaofeng
This is an automated email from the ASF dual-hosted git repository.

xiaofeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


The following commit(s) were added to refs/heads/master by this push:
 new c97e718d Uppdate release steps
c97e718d is described below

commit c97e718d67c2089d6d5ca1329121eca851b81a60
Author: Xiaofeng Wang 
AuthorDate: Mon Jan 23 08:12:53 2023 +

Uppdate release steps
---
 community/release_cn.md | 2 +-
 community/release_en.md | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/community/release_cn.md b/community/release_cn.md
index e684c4bf..bf49b5c8 100644
--- a/community/release_cn.md
+++ b/community/release_cn.md
@@ -349,7 +349,7 @@ diff -r brpc-1.0.0 apache-brpc-1.0.0-src
 
 ## 1. 投票阶段
 
-1. 发起投票邮件到 dev@brpc.apache.org。PPMC 需要先按文档检查版本的正确性,然后再进行投票。经过至少 72 小时并统计到 3 个 
+1 PPMC member 票后,即可进入下一阶段。
+1. 发起投票邮件到 dev@brpc.apache.org。PMC 需要先按文档检查版本的正确性,然后再进行投票。经过至少 72 小时并统计到 3 个 
+1 PMC member 票后,即可进入下一阶段。
 2. 宣布投票结果,发起投票结果邮件到 dev@brpc.apache.org。
 
 ## 2. 投票邮件模板
diff --git a/community/release_en.md b/community/release_en.md
index 77945124..46041631 100644
--- a/community/release_en.md
+++ b/community/release_en.md
@@ -352,7 +352,7 @@ diff -r brpc-1.0.0 apache-brpc-1.0.0-src
 
 ## 1. Vote stage
 
-1. Send a voting email to `dev@brpc.apache.org`. PPMC needs to check the 
correctness of the version according to the document before voting. After at 
least 72 hours and 3 +1 PPMC member votes, you can move to the next stage.
+1. Send a voting email to `dev@brpc.apache.org`. PMC needs to check the 
correctness of the version according to the document before voting. After at 
least 72 hours and 3 +1 PMC member votes, you can move to the next stage.
 
 2. Announce the voting result and send the voting result to 
dev@brpc.apache.org.
 


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [brpc] wwbmmm commented on a diff in pull request #2093: Add Mysql Protocol

2023-01-23 Thread via GitHub


wwbmmm commented on code in PR #2093:
URL: https://github.com/apache/brpc/pull/2093#discussion_r1073125489


##
docs/cn/mysql_client.md:
##
@@ -0,0 +1,562 @@
+[MySQL](https://www.mysql.com/)是著名的开源的关系型数据库,为了使用户更快捷地访问mysql并充分利用bthread的并发能力,brpc直接支持mysql协议。示例程序:[example/mysql_c++](https://github.com/brpc/brpc/tree/master/example/mysql_c++/)
+
+**注意**:只支持MySQL 4.1 及之后的版本的文本协议,支持事务,不支持Prepared 
statement。目前支持的鉴权方式为mysql_native_password,使用事务的时候不支持single模式。

Review Comment:
   现在是不是支持Prepared statement了



##
docs/cn/mysql_client.md:
##
@@ -0,0 +1,562 @@
+[MySQL](https://www.mysql.com/)是著名的开源的关系型数据库,为了使用户更快捷地访问mysql并充分利用bthread的并发能力,brpc直接支持mysql协议。示例程序:[example/mysql_c++](https://github.com/brpc/brpc/tree/master/example/mysql_c++/)
+
+**注意**:只支持MySQL 4.1 及之后的版本的文本协议,支持事务,不支持Prepared 
statement。目前支持的鉴权方式为mysql_native_password,使用事务的时候不支持single模式。
+
+相比使用[libmysqlclient](https://dev.mysql.com/downloads/connector/c/)(官方client)的优势有:
+
+- 线程安全。用户不需要为每个线程建立独立的client。
+- 支持同步、异步、半同步等访问方式,能使用[ParallelChannel等](combo_channel.md)组合访问方式。
+- 支持多种[连接方式](client.md#连接方式)。支持超时、backup request、取消、tracing、内置服务等一系列brpc提供的福利。
+- 明确的返回类型校验,如果使用了不正确的变量接受mysql的数据类型,将抛出异常。
+- 调用mysql标准库会阻塞框架的并发能力,使用本实现将能充分利用brpc框架的并发能力。
+- 使用brpc实现的mysql不会造成pthread的阻塞,使用libmysqlclient会阻塞pthread 
[线程相关](bthread.md),使用mysql的异步api会使编程变得很复杂。
+# 访问mysql
+
+创建一个访问mysql的Channel:
+
+```c++
+# include 
+# include 
+# include 
+
+brpc::ChannelOptions options;
+options.protocol = brpc::PROTOCOL_MYSQL;
+options.connection_type = FLAGS_connection_type;
+options.timeout_ms = FLAGS_timeout_ms /*milliseconds*/;
+options.max_retry = FLAGS_max_retry;
+options.auth = new brpc::policy::MysqlAuthenticator("yangliming01", "123456", 
"test", 
+"charset=utf8&collation_connection=utf8_unicode_ci");
+if (channel.Init("127.0.0.1", 3306, &options) != 0) {
+LOG(ERROR) << "Fail to initialize channel";
+return -1;
+}
+```
+
+向mysql发起命令。
+
+```c++
+// 执行各种mysql命令,可以批量执行命令如:"select * from tab1;select * from tab2"
+std::string command = "show databases"; // 
select,delete,update,insert,create,drop ...
+brpc::MysqlRequest request;
+if (!request.Query(command)) {
+LOG(ERROR) << "Fail to add command";
+return false;
+}
+brpc::MysqlResponse response;
+brpc::Controller cntl;
+channel.CallMethod(NULL, &cntl, &request, &response, NULL);
+if (!cntl.Failed()) {
+std::cout << response << std::endl;
+} else {
+LOG(ERROR) << "Fail to access mysql, " << cntl.ErrorText();
+return false;
+}
+return true;
+```
+
+上述代码的说明:
+
+- 
请求类型必须为MysqlRequest,回复类型必须为MysqlResponse,否则CallMethod会失败。不需要stub,直接调用channel.CallMethod,method填NULL。
+- 调用request.Query()传入要执行的命令,可以批量执行命令,多个命令用分号隔开。
+- 
依次调用response.reply(X)弹出操作结果,根据返回类型的不同,选择不同的类型接收,如:MysqlReply::Ok,MysqlReply::Error,const
 MysqlReply::Columnconst MysqlReply::Row等。
+- 如果只有一条命令则reply为1个,如果为批量操作返回的reply为多个。
+
+目前支持的请求操作有:
+
+```c++
+bool Query(const butil::StringPiece& command);
+```
+
+对应的回复操作:
+
+```c++
+// 返回不同类型的结果
+const MysqlReply::Auth& auth() const;
+const MysqlReply::Ok& ok() const;
+const MysqlReply::Error& error() const;
+const MysqlReply::Eof& eof() const;
+// 对result set结果集的操作
+// get column number
+uint64_t MysqlReply::column_number() const;
+// get one column
+const MysqlReply::Column& MysqlReply::column(const uint64_t index) const;
+// get row number
+uint64_t MysqlReply::row_number() const;
+// get one row
+const MysqlReply::Row& MysqlReply::next() const;
+// 结果集中每个字段的操作
+const MysqlReply::Field& MysqlReply::Row::field(const uint64_t index) const;
+```
+
+# 事务操作
+
+事务可以保证在一个事务中的多个RPC请求最终要么都成功,要么都失败。
+
+```c++
+rpc::Channel channel;

Review Comment:
   这一段初始化Channel的代码可以略去



##
src/brpc/controller.h:
##
@@ -815,6 +824,13 @@ friend void 
policy::ProcessThriftRequest(InputMessageBase*);
 // Defined at both sides
 StreamSettings *_remote_stream_settings;
 
+// controller bind socket action
+BindSockAction _bind_sock_action;
+// controller bind sock
+SocketUniquePtr _bind_sock;
+// sql prepare statement
+MysqlStatementStub *_stmt;

Review Comment:
   建议叫_mysql_stmt



##
docs/cn/mysql_client.md:
##
@@ -0,0 +1,562 @@
+[MySQL](https://www.mysql.com/)是著名的开源的关系型数据库,为了使用户更快捷地访问mysql并充分利用bthread的并发能力,brpc直接支持mysql协议。示例程序:[example/mysql_c++](https://github.com/brpc/brpc/tree/master/example/mysql_c++/)
+
+**注意**:只支持MySQL 4.1 及之后的版本的文本协议,支持事务,不支持Prepared 
statement。目前支持的鉴权方式为mysql_native_password,使用事务的时候不支持single模式。
+
+相比使用[libmysqlclient](https://dev.mysql.com/downloads/connector/c/)(官方client)的优势有:
+
+- 线程安全。用户不需要为每个线程建立独立的client。
+- 支持同步、异步、半同步等访问方式,能使用[ParallelChannel等](combo_channel.md)组合访问方式。
+- 支持多种[连接方式](client.md#连接方式)。支持超时、backup request、取消、tracing、内置服务等一系列brpc提供的福利。
+- 明确的返回类型校验,如果使用了不正确的变量接受mysql的数据类型,将抛出异常。
+- 调用mysql标准库会阻塞框架的并发能力,使用本实现将能充分利用brpc框架的并发能力。
+- 使用brpc实现的mysql不会造成pthread的阻塞,使用libmysqlclient会阻塞pthread 
[线程相关](bthread.md),使用mysql的异步api会使编程变得很复杂。
+# 访问mysql
+
+创建一个访问mysql的Channel:
+
+```c++
+# include 
+# incl

[GitHub] [brpc] chenBright opened a new pull request, #2097: show server concurrency in status service

2023-01-23 Thread via GitHub


chenBright opened a new pull request, #2097:
URL: https://github.com/apache/brpc/pull/2097

   ### What problem does this PR solve?
   
   Issue Number:
   
   Problem Summary: 内置服务目前只展示了方法级别的并发数,并未展示server级别的并发数。
   
   ### What is changed and the side effects?
   
   Changed:
   增加bvar统计server级别的并发数,同时在内置服务页面展示该并发数。
   
   Side effects:
   - Performance effects(性能影响):
   
   - Breaking backward compatibility(向后兼容性): 
   
   ---
   ### Check List:
   - Please make sure your changes are compilable(请确保你的更改可以通过编译).
   - When providing us with a new feature, it is best to add related 
tests(如果你向我们增加一个新的功能, 请添加相关测试).
   - Please follow [Contributor Covenant Code of 
Conduct](../../master/CODE_OF_CONDUCT.md).(请遵循贡献者准则).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [brpc] wasphin commented on a diff in pull request #2086: Fix butex wait_pthread handle EINTR

2023-01-23 Thread via GitHub


wasphin commented on code in PR #2086:
URL: https://github.com/apache/brpc/pull/2086#discussion_r1084718111


##
src/bthread/butex.cpp:
##
@@ -137,27 +137,45 @@ static void wakeup_pthread(ButexPthreadWaiter* pw) {
 
 bool erase_from_butex(ButexWaiter*, bool, WaiterState);
 
-int wait_pthread(ButexPthreadWaiter& pw, timespec* ptimeout) {
+int wait_pthread(ButexPthreadWaiter& pw, const timespec* abstime) {
+timespec * ptimeout = NULL;

Review Comment:
   * 靠左



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [brpc] wasphin commented on a diff in pull request #2086: Fix butex wait_pthread handle EINTR

2023-01-23 Thread via GitHub


wasphin commented on code in PR #2086:
URL: https://github.com/apache/brpc/pull/2086#discussion_r1084718111


##
src/bthread/butex.cpp:
##
@@ -137,27 +137,45 @@ static void wakeup_pthread(ButexPthreadWaiter* pw) {
 
 bool erase_from_butex(ButexWaiter*, bool, WaiterState);
 
-int wait_pthread(ButexPthreadWaiter& pw, timespec* ptimeout) {
+int wait_pthread(ButexPthreadWaiter& pw, const timespec* abstime) {
+timespec * ptimeout = NULL;

Review Comment:
   `*` 靠左



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [brpc] jenrryyou commented on a diff in pull request #2086: Fix butex wait_pthread handle EINTR

2023-01-23 Thread via GitHub


jenrryyou commented on code in PR #2086:
URL: https://github.com/apache/brpc/pull/2086#discussion_r1084834042


##
src/bthread/butex.cpp:
##
@@ -137,27 +137,45 @@ static void wakeup_pthread(ButexPthreadWaiter* pw) {
 
 bool erase_from_butex(ButexWaiter*, bool, WaiterState);
 
-int wait_pthread(ButexPthreadWaiter& pw, timespec* ptimeout) {
+int wait_pthread(ButexPthreadWaiter& pw, const timespec* abstime) {
+timespec * ptimeout = NULL;
+timespec timeout;
+int64_t timeout_us = 0;
+int rc;
+
 while (true) {
-const int rc = futex_wait_private(&pw.sig, PTHREAD_NOT_SIGNALLED, 
ptimeout);
-if (PTHREAD_NOT_SIGNALLED != pw.sig.load(butil::memory_order_acquire)) 
{
-// If `sig' is changed, wakeup_pthread() must be called and `pw'
-// is already removed from the butex.
-// Acquire fence makes this thread sees changes before wakeup.
-return rc;
+if (abstime != NULL) {
+timeout_us = butil::timespec_to_microseconds(*abstime) - 
butil::gettimeofday_us();
+timeout = butil::microseconds_to_timespec(timeout_us);
+ptimeout = &timeout;
 }
-if (rc != 0 && errno == ETIMEDOUT) {
-// Note that we don't handle the EINTR from futex_wait here since
-// pthreads waiting on a butex should behave similarly as bthreads
-// which are not able to be woken-up by signals.
-// EINTR on butex is only producible by TaskGroup::interrupt().
-
-// `pw' is still in the queue, remove it.
+if (timeout_us > MIN_SLEEP_US || abstime == NULL) {
+rc = futex_wait_private(&pw.sig, PTHREAD_NOT_SIGNALLED, ptimeout);
+if (PTHREAD_NOT_SIGNALLED != 
pw.sig.load(butil::memory_order_acquire)) {
+// If `sig' is changed, wakeup_pthread() must be called and 
`pw'
+// is already removed from the butex.
+// Acquire fence makes this thread sees changes before wakeup.
+return rc;
+}
+}
+else {

Review Comment:
   OK



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [brpc] jenrryyou commented on a diff in pull request #2086: Fix butex wait_pthread handle EINTR

2023-01-23 Thread via GitHub


jenrryyou commented on code in PR #2086:
URL: https://github.com/apache/brpc/pull/2086#discussion_r1084834153


##
src/bthread/butex.cpp:
##
@@ -137,27 +137,45 @@ static void wakeup_pthread(ButexPthreadWaiter* pw) {
 
 bool erase_from_butex(ButexWaiter*, bool, WaiterState);
 
-int wait_pthread(ButexPthreadWaiter& pw, timespec* ptimeout) {
+int wait_pthread(ButexPthreadWaiter& pw, const timespec* abstime) {
+timespec * ptimeout = NULL;
+timespec timeout;
+int64_t timeout_us = 0;
+int rc;
+
 while (true) {
-const int rc = futex_wait_private(&pw.sig, PTHREAD_NOT_SIGNALLED, 
ptimeout);
-if (PTHREAD_NOT_SIGNALLED != pw.sig.load(butil::memory_order_acquire)) 
{
-// If `sig' is changed, wakeup_pthread() must be called and `pw'
-// is already removed from the butex.
-// Acquire fence makes this thread sees changes before wakeup.
-return rc;
+if (abstime != NULL) {
+timeout_us = butil::timespec_to_microseconds(*abstime) - 
butil::gettimeofday_us();
+timeout = butil::microseconds_to_timespec(timeout_us);
+ptimeout = &timeout;
 }
-if (rc != 0 && errno == ETIMEDOUT) {
-// Note that we don't handle the EINTR from futex_wait here since
-// pthreads waiting on a butex should behave similarly as bthreads
-// which are not able to be woken-up by signals.
-// EINTR on butex is only producible by TaskGroup::interrupt().
-
-// `pw' is still in the queue, remove it.
+if (timeout_us > MIN_SLEEP_US || abstime == NULL) {
+rc = futex_wait_private(&pw.sig, PTHREAD_NOT_SIGNALLED, ptimeout);
+if (PTHREAD_NOT_SIGNALLED != 
pw.sig.load(butil::memory_order_acquire)) {
+// If `sig' is changed, wakeup_pthread() must be called and 
`pw'
+// is already removed from the butex.
+// Acquire fence makes this thread sees changes before wakeup.
+return rc;
+}
+}
+else {
+errno = ETIMEDOUT;
+rc = -1;
+}
+// Handle EINTR or ETIMEDOUT when abstime is valid
+if (rc != 0 && abstime != NULL) {
+// Handle the EINTR from futex_wait
+if (errno != ETIMEDOUT) {

Review Comment:
   已修改
   
   



##
src/bthread/butex.cpp:
##
@@ -137,27 +137,45 @@ static void wakeup_pthread(ButexPthreadWaiter* pw) {
 
 bool erase_from_butex(ButexWaiter*, bool, WaiterState);
 
-int wait_pthread(ButexPthreadWaiter& pw, timespec* ptimeout) {
+int wait_pthread(ButexPthreadWaiter& pw, const timespec* abstime) {
+timespec * ptimeout = NULL;

Review Comment:
   已修改



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org