jamesge commented on a change in pull request #692: Add Mysql Protocol, only 
support text protocol now, not support trans…
URL: https://github.com/apache/incubator-brpc/pull/692#discussion_r267203881
 
 

 ##########
 File path: src/brpc/mysql.h
 ##########
 @@ -0,0 +1,187 @@
+// Copyright (c) 2019 Baidu, Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Authors: Yang,Liming ([email protected])
+
+#ifndef BRPC_MYSQL_H
+#define BRPC_MYSQL_H
+
+#include <string>
+#include <google/protobuf/stubs/common.h>
+
+#include <google/protobuf/generated_message_util.h>
+#include <google/protobuf/repeated_field.h>
+#include <google/protobuf/extension_set.h>
+#include <google/protobuf/generated_message_reflection.h>
+#include "google/protobuf/descriptor.pb.h"
+
+#include "butil/iobuf.h"
+#include "butil/strings/string_piece.h"
+#include "butil/arena.h"
+#include "brpc/mysql_reply.h"
+
+namespace brpc {
+// Request to mysql.
+// Notice that you can pipeline multiple commands in one request and sent
+// them to ONE mysql-server together.
+// Example:
+//   MysqlRequest request;
+//   request.Query("select * from table");
+//   MysqlResponse response;
+//   channel.CallMethod(NULL, &controller, &request, &response, NULL/*done*/);
+//   if (!cntl.Failed()) {
+//       LOG(INFO) << response.reply(0);
+//   }
+class MysqlRequest : public ::google::protobuf::Message {
+public:
+    MysqlRequest();
+    virtual ~MysqlRequest();
+    MysqlRequest(const MysqlRequest& from);
+    inline MysqlRequest& operator=(const MysqlRequest& from) {
+        CopyFrom(from);
+        return *this;
+    }
+    void Swap(MysqlRequest* other);
+
+    // Serialize the request into `buf'. Return true on success.
+    bool SerializeTo(butil::IOBuf* buf) const;
+
+    // Protobuf methods.
+    MysqlRequest* New() const;
+    void CopyFrom(const ::google::protobuf::Message& from);
+    void MergeFrom(const ::google::protobuf::Message& from);
+    void CopyFrom(const MysqlRequest& from);
+    void MergeFrom(const MysqlRequest& from);
+    void Clear();
+
+    int ByteSize() const;
+    bool MergePartialFromCodedStream(::google::protobuf::io::CodedInputStream* 
input);
+    void SerializeWithCachedSizes(::google::protobuf::io::CodedOutputStream* 
output) const;
+    ::google::protobuf::uint8* SerializeWithCachedSizesToArray(
+        ::google::protobuf::uint8* output) const;
+    int GetCachedSize() const {
+        return _cached_size_;
+    }
+
+    static const ::google::protobuf::Descriptor* descriptor();
+    static const MysqlRequest& default_instance();
+    ::google::protobuf::Metadata GetMetadata() const;
+
+    bool Query(const std::string& stmt);
+    bool Query(const char* stmt);
 
 Review comment:
   参数也可以统一成StringPiece了?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to