You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2022/07/23 14:44:23 UTC

[dubbo-rust] branch poc-idl updated (69249f0 -> 7dcc162)

This is an automated email from the ASF dual-hosted git repository.

liujun pushed a change to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git


    from 69249f0  Merge pull request #10 from dongzl/license-check
     new 13d77d4  feat: client server message
     new 3a8b693  feat: protobuf example
     new a44357d  feat: gen rpc code form proto service defined
     new 1182f56  init readme
     new 8d48700  update
     new 3a64825  update
     new 8f07dad  update
     new b70780a  update
     new 60bfedf  finished 1.0.0
     new d4d667e  Update server.rs
     new 0a38b4c  Update client.rs
     new dae80cd  Update server.rs
     new 7f014c4  Delete .DS_Store
     new bd85362  .DS_Store banished!
     new 7dcc162  Merge pull request #20 from Johankoi/main

The 35 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Cargo.toml                                  |   3 +
 README.md                                   |  43 ++-
 README_CN.md                                |  42 +++
 dubbo-build/Cargo.toml                      |  12 +
 dubbo-build/src/generator.rs                | 184 +++++++++++
 {config => dubbo-build}/src/lib.rs          |  14 +-
 examples/grpc-gen/Cargo.toml                |  32 ++
 examples/grpc-gen/build.rs                  |  11 +
 examples/grpc-gen/pb/greeter.proto          |  14 +
 examples/grpc-gen/src/client.rs             |  10 +
 examples/grpc-gen/src/greeter.rs            |  97 ++++++
 examples/grpc-gen/src/lib.rs                |   6 +
 examples/grpc-gen/src/server.rs             |  38 +++
 examples/protobuf-transport/Cargo.toml      |  30 ++
 examples/protobuf-transport/build.rs        |   9 +
 examples/protobuf-transport/pb/person.proto |  26 ++
 examples/protobuf-transport/src/client.rs   |  33 ++
 examples/protobuf-transport/src/lib.rs      |   7 +
 examples/protobuf-transport/src/person.rs   |  35 ++
 examples/protobuf-transport/src/server.rs   |  11 +
 xds/Cargo.toml                              |  22 ++
 xds/src/client/client.rs                    |  90 ++++++
 xds/src/client/mod.rs                       |   4 +
 xds/src/error.rs                            | 153 +++++++++
 xds/src/lib.rs                              |  30 +-
 xds/src/protocol/error.rs                   | 206 ++++++++++++
 xds/src/protocol/message.rs                 | 485 ++++++++++++++++++++++++++++
 xds/src/{client => protocol}/mod.rs         |   7 +
 xds/src/request.rs                          | 126 ++++++++
 xds/src/response.rs                         | 139 ++++++++
 xds/src/server/mod.rs                       |   4 +
 xds/src/server/server.rs                    |  75 +++++
 config/src/lib.rs => xds/src/util.rs        |  17 +-
 33 files changed, 1996 insertions(+), 19 deletions(-)
 create mode 100644 dubbo-build/Cargo.toml
 create mode 100644 dubbo-build/src/generator.rs
 copy {config => dubbo-build}/src/lib.rs (81%)
 create mode 100644 examples/grpc-gen/Cargo.toml
 create mode 100644 examples/grpc-gen/build.rs
 create mode 100644 examples/grpc-gen/pb/greeter.proto
 create mode 100644 examples/grpc-gen/src/client.rs
 create mode 100644 examples/grpc-gen/src/greeter.rs
 create mode 100644 examples/grpc-gen/src/lib.rs
 create mode 100644 examples/grpc-gen/src/server.rs
 create mode 100644 examples/protobuf-transport/Cargo.toml
 create mode 100644 examples/protobuf-transport/build.rs
 create mode 100644 examples/protobuf-transport/pb/person.proto
 create mode 100644 examples/protobuf-transport/src/client.rs
 create mode 100644 examples/protobuf-transport/src/lib.rs
 create mode 100644 examples/protobuf-transport/src/person.rs
 create mode 100644 examples/protobuf-transport/src/server.rs
 create mode 100644 xds/src/error.rs
 create mode 100644 xds/src/protocol/error.rs
 create mode 100644 xds/src/protocol/message.rs
 copy xds/src/{client => protocol}/mod.rs (91%)
 create mode 100644 xds/src/request.rs
 create mode 100644 xds/src/response.rs
 copy config/src/lib.rs => xds/src/util.rs (71%)


[dubbo-rust] 04/35: modify package info

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit e33e22ced34f744f3cfdb9a97ee4972bec225c53
Author: hanxiaoqing <ha...@rongcloud.cn>
AuthorDate: Mon Apr 25 14:35:33 2022 +0800

    modify package info
    
    Signed-off-by: hanxiaoqing <ha...@rongcloud.cn>
---
 common/Cargo.toml   |   2 +-
 config/Cargo.toml   |   2 +-
 examples/Cargo.toml |   4 +-
 examples/LICENSE    | 210 +++++++++++++++++++++++++++++++++++++++++++++++-----
 metadata/Cargo.toml |   2 +-
 protocol/Cargo.toml |   2 +-
 registry/Cargo.toml |   2 +-
 xds/Cargo.toml      |   2 +-
 8 files changed, 198 insertions(+), 28 deletions(-)

diff --git a/common/Cargo.toml b/common/Cargo.toml
index b7723d9..09624c9 100644
--- a/common/Cargo.toml
+++ b/common/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "common"
 version = "0.1.0"
-edition = "2021"
+edition = "2022"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
diff --git a/config/Cargo.toml b/config/Cargo.toml
index b8afece..f074d2d 100644
--- a/config/Cargo.toml
+++ b/config/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "config"
 version = "0.1.0"
-edition = "2021"
+edition = "2022"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
diff --git a/examples/Cargo.toml b/examples/Cargo.toml
index 3287f9c..a477bf0 100644
--- a/examples/Cargo.toml
+++ b/examples/Cargo.toml
@@ -1,10 +1,8 @@
 [package]
-authors = ["Johankio Smith <jo...@1991.com>"]
-edition = "2018"
-license = "MIT"
 name = "examples"
 publish = false
 version = "0.1.0"
+edition = "2022"
 
 [[bin]]
 name = "helloworld-server"
diff --git a/examples/LICENSE b/examples/LICENSE
index 3077098..d80bbda 100644
--- a/examples/LICENSE
+++ b/examples/LICENSE
@@ -1,19 +1,191 @@
-Copyright (c) 2020 Lucio Franco
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   Copyright (c) 2016 ~ 2018 Alex Stocks.
+
+   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.
diff --git a/metadata/Cargo.toml b/metadata/Cargo.toml
index a600f4c..7fda9ec 100644
--- a/metadata/Cargo.toml
+++ b/metadata/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "metadata"
 version = "0.1.0"
-edition = "2021"
+edition = "2022"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
diff --git a/protocol/Cargo.toml b/protocol/Cargo.toml
index 77c8260..8000b3c 100644
--- a/protocol/Cargo.toml
+++ b/protocol/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "protocol"
 version = "0.1.0"
-edition = "2021"
+edition = "2022"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
diff --git a/registry/Cargo.toml b/registry/Cargo.toml
index 89c58fc..4e56c99 100644
--- a/registry/Cargo.toml
+++ b/registry/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "registry"
 version = "0.1.0"
-edition = "2021"
+edition = "2022"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
diff --git a/xds/Cargo.toml b/xds/Cargo.toml
index 75e2515..3b89e37 100644
--- a/xds/Cargo.toml
+++ b/xds/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "xds"
 version = "0.1.0"
-edition = "2021"
+edition = "2022"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 


[dubbo-rust] 12/35: Enable Github Actions CI workflow #6

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 1f5fb8eebe11b0ad48e8e6e62acce969372a331f
Merge: 28eab63 2e73b00
Author: ken.lj <ke...@gmail.com>
AuthorDate: Fri May 6 11:02:36 2022 +0800

    Enable Github Actions CI workflow #6
    
    Fix edition and add workflow

 .github/workflows/CI.yml | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
 common/Cargo.toml        |  2 +-
 config/Cargo.toml        |  2 +-
 metadata/Cargo.toml      |  2 +-
 protocol/Cargo.toml      |  2 +-
 registry/Cargo.toml      |  2 +-
 xds/Cargo.toml           |  2 +-
 7 files changed, 60 insertions(+), 6 deletions(-)


[dubbo-rust] 16/35: Fix: fix github actions config file name.

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 463f84ebde97455a9ca249c9b058dfe439fd55d7
Author: Zonglei Dong <do...@apache.org>
AuthorDate: Sat May 14 15:27:43 2022 +0800

    Fix: fix github actions config file name.
---
 .github/workflows/{CI.yml => github-actions.yml} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/.github/workflows/CI.yml b/.github/workflows/github-actions.yml
similarity index 100%
rename from .github/workflows/CI.yml
rename to .github/workflows/github-actions.yml


[dubbo-rust] 20/35: Merge pull request #10 from dongzl/license-check

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 69249f06079b343aecc5549cfc70093c08f0d099
Merge: 2b2eef4 fbd62f3
Author: ken.lj <ke...@gmail.com>
AuthorDate: Thu May 26 10:28:43 2022 +0800

    Merge pull request #10 from dongzl/license-check
    
    add license check github action.

 .asf.yaml                                        |  2 -
 .github/workflows/{CI.yml => github-actions.yml} |  0
 .github/workflows/licence-checker.yml            | 45 +++++++++++++++
 .licenserc.yaml                                  | 72 ++++++++++++++++++++++++
 common/src/lib.rs                                | 17 ++++++
 config/src/lib.rs                                | 17 ++++++
 metadata/src/lib.rs                              | 17 ++++++
 protocol/src/lib.rs                              | 17 ++++++
 registry/src/lib.rs                              | 17 ++++++
 xds/src/client/client.rs                         | 16 ++++++
 xds/src/client/mod.rs                            | 16 ++++++
 xds/src/lib.rs                                   | 17 ++++++
 xds/src/server/mod.rs                            | 16 ++++++
 xds/src/server/server.rs                         | 16 ++++++
 14 files changed, 283 insertions(+), 2 deletions(-)


[dubbo-rust] 08/35: Fix: edition: 2021

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 9b974733ada7a8b85d8450c65c2ef0b73b49afbe
Author: johankoi <jo...@163.com>
AuthorDate: Tue Apr 26 15:09:55 2022 +0800

    Fix: edition: 2021
    
    Signed-off-by: johankoi <jo...@163.com>
---
 common/Cargo.toml   | 2 +-
 config/Cargo.toml   | 2 +-
 metadata/Cargo.toml | 2 +-
 protocol/Cargo.toml | 2 +-
 registry/Cargo.toml | 2 +-
 xds/Cargo.toml      | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/common/Cargo.toml b/common/Cargo.toml
index 09624c9..b7723d9 100644
--- a/common/Cargo.toml
+++ b/common/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "common"
 version = "0.1.0"
-edition = "2022"
+edition = "2021"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
diff --git a/config/Cargo.toml b/config/Cargo.toml
index f074d2d..b8afece 100644
--- a/config/Cargo.toml
+++ b/config/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "config"
 version = "0.1.0"
-edition = "2022"
+edition = "2021"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
diff --git a/metadata/Cargo.toml b/metadata/Cargo.toml
index 7fda9ec..a600f4c 100644
--- a/metadata/Cargo.toml
+++ b/metadata/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "metadata"
 version = "0.1.0"
-edition = "2022"
+edition = "2021"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
diff --git a/protocol/Cargo.toml b/protocol/Cargo.toml
index 8000b3c..77c8260 100644
--- a/protocol/Cargo.toml
+++ b/protocol/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "protocol"
 version = "0.1.0"
-edition = "2022"
+edition = "2021"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
diff --git a/registry/Cargo.toml b/registry/Cargo.toml
index 4e56c99..89c58fc 100644
--- a/registry/Cargo.toml
+++ b/registry/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "registry"
 version = "0.1.0"
-edition = "2022"
+edition = "2021"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
diff --git a/xds/Cargo.toml b/xds/Cargo.toml
index 3b89e37..75e2515 100644
--- a/xds/Cargo.toml
+++ b/xds/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "xds"
 version = "0.1.0"
-edition = "2022"
+edition = "2021"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 


[dubbo-rust] 28/35: update

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit b70780a133896a2c82bc8a5e0470358613046c82
Author: Johankoi <Jo...@163.com>
AuthorDate: Thu Jul 14 16:11:51 2022 +0800

    update
---
 README.md | 43 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index f39d9ab..9826297 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,42 @@
-# dubbo-rust
+dubbo-rust
+=========
+
+Rust implementation of [gRPC] protocol for [Dubbo], under development.
+
+
+[Examples] | [Docs]
+
+## Overview
+
+[`dubbo-rust`] is composed of three main components: the generic gRPC implementation, the gRPC codegen
+implementation with dubbo-build powered by [`prost`]. The transporter layer implementation can support any HTTP/2
+implementation is based on [`hyper`], [`tower`]. The message layer implementation can support any user defined bytes format.
+
+## Features
+- async/await service trait define
+- generate gRPC code for easy use
+- message byte define
+
+## Getting Started
+Examples can be found in [`examples`]
+
+
+### Tutorials
+
+- The [`protobuf-transport`] example provides a basic example for testing transport protobuf-message-object-data via HTTP/2.
+- The [`grpc-gen`] example provides a complete example of using bubbo-rust client/server grpc.
+
+### Contribution
+
+[gRPC]: https://grpc.io
+[dubbo]: https://dubbo.apache.org/en/
+[`prost`]: https://github.com/tokio-rs/prost
+[`hyper`]: https://github.com/hyperium/hyper
+[`tower`]: https://github.com/tower-rs/tower
+[Examples]: https://github.com/Johankoi/dubbo-rust/tree/main/examples
+[`examples`]: https://github.com/Johankoi/dubbo-rust/tree/main/examples
+[`protobuf-transport`]: https://github.com/Johankoi/dubbo-rust/tree/main/examples/protobuf-transport
+[`grpc-gen`]: https://github.com/Johankoi/dubbo-rust/tree/main/examples/grpc-gen
+
+
+


[dubbo-rust] 25/35: update

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 8d4870066b2ffdb5555fc85a26fc83ff5c8096d1
Author: Johankoi <Jo...@163.com>
AuthorDate: Thu Jul 14 12:02:09 2022 +0800

    update
---
 README_CN.md | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/README_CN.md b/README_CN.md
index 82f4595..99456e3 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -10,7 +10,7 @@ Rust implementation of [gRPC] protocol for [Dubbo], under development.
 
 [`bubbo-rust`] is composed of three main components: the generic gRPC implementation, the gRPC codegen 
 implementation with dubbo-build powered by [`prost`]. The transporter layer implementation can support any HTTP/2
-implementation is based on [`hyper`] [`tower`]. The message layer implementation can support any user defined bytes format.
+implementation is based on [`hyper`], [`tower`]. The message layer implementation can support any user defined bytes format.
 
 ## Features
 - async/await service trait define
@@ -27,11 +27,13 @@ Examples can be found in [`examples`]
 - The [`grpc-gen`][grpc-gen] example provides a complete example of using bubbo-rust client/server grpc.
 
 ### Contribution
+
 [gRPC]: https://grpc.io
 [dubbo]: https://dubbo.apache.org/en/
 [`prost`]: https://github.com/tokio-rs/prost
 [`hyper`]: https://github.com/hyperium/hyper
 [`tower`]: https://github.com/tower-rs/tower
+[Examples]: https://github.com/Johankoi/dubbo-rust/tree/main/examples
 [`examples`]: https://github.com/Johankoi/dubbo-rust/tree/main/examples
 [`protobuf-transport`]: https://github.com/Johankoi/dubbo-rust/tree/main/examples/protobuf-transport
 [`grpc-gen`]: https://github.com/Johankoi/dubbo-rust/tree/main/examples/grpc-gen


[dubbo-rust] 24/35: init readme

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 1182f56fa3912f23976176443ba6544d5c8c82b4
Author: Johankoi <Jo...@163.com>
AuthorDate: Thu Jul 14 12:01:03 2022 +0800

    init readme
---
 README_CN.md | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/README_CN.md b/README_CN.md
index e69de29..82f4595 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -0,0 +1,40 @@
+bubbo-rust
+=========
+
+Rust implementation of [gRPC] protocol for [Dubbo], under development.
+
+
+[Examples] | [Docs] 
+
+## Overview
+
+[`bubbo-rust`] is composed of three main components: the generic gRPC implementation, the gRPC codegen 
+implementation with dubbo-build powered by [`prost`]. The transporter layer implementation can support any HTTP/2
+implementation is based on [`hyper`] [`tower`]. The message layer implementation can support any user defined bytes format.
+
+## Features
+- async/await service trait define
+- generate gRPC code for easy use
+- message byte define 
+
+## Getting Started
+Examples can be found in [`examples`]
+
+
+### Tutorials
+
+- The [`protobuf-transport`][protobuf-transport] example provides a basic example for testing transport protobuf-message-object-data via HTTP/2.
+- The [`grpc-gen`][grpc-gen] example provides a complete example of using bubbo-rust client/server grpc.
+
+### Contribution
+[gRPC]: https://grpc.io
+[dubbo]: https://dubbo.apache.org/en/
+[`prost`]: https://github.com/tokio-rs/prost
+[`hyper`]: https://github.com/hyperium/hyper
+[`tower`]: https://github.com/tower-rs/tower
+[`examples`]: https://github.com/Johankoi/dubbo-rust/tree/main/examples
+[`protobuf-transport`]: https://github.com/Johankoi/dubbo-rust/tree/main/examples/protobuf-transport
+[`grpc-gen`]: https://github.com/Johankoi/dubbo-rust/tree/main/examples/grpc-gen
+
+
+


[dubbo-rust] 11/35: Merge branch 'main' into dubbo_rust_1.0

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 2e73b000b3ef87077860542d9a5e17d40d9377f3
Merge: 9b97473 04a3e3f
Author: johankoi <jo...@163.com>
AuthorDate: Wed Apr 27 00:37:37 2022 +0800

    Merge branch 'main' into dubbo_rust_1.0

 .github/workflows/CI.yml | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)


[dubbo-rust] 23/35: feat: gen rpc code form proto service defined

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit a44357d0aad89f04bc9937c190d954a6e070d8a4
Author: johankoi <jo...@163.com>
AuthorDate: Thu Jul 14 04:25:27 2022 +0800

    feat: gen rpc code form proto service defined
    
    Signed-off-by: johankoi <jo...@163.com>
---
 Cargo.toml                                         |   6 +-
 dubbo-build/Cargo.toml                             |  12 ++
 dubbo-build/src/generator.rs                       | 136 +++++++++++++++++++++
 dubbo-build/src/lib.rs                             |   8 ++
 examples/grpc-gen/Cargo.toml                       |  20 +++
 examples/grpc-gen/build.rs                         |  12 ++
 .../pb_message => grpc-gen}/pb/greeter.proto       |   0
 examples/grpc-gen/src/greeter.rs                   |  73 +++++++++++
 examples/grpc-gen/src/main.rs                      |  12 ++
 examples/protobuf-transport/Cargo.toml             |  30 +++++
 examples/protobuf-transport/build.rs               |   9 ++
 .../pb/person.proto                                |   0
 examples/protobuf-transport/src/client.rs          |  33 +++++
 examples/protobuf-transport/src/lib.rs             |   7 ++
 .../src/pb => protobuf-transport/src}/person.rs    |   0
 .../main.rs => protobuf-transport/src/server.rs}   |   2 +-
 examples/protobuf/client/Cargo.toml                |  14 ---
 examples/protobuf/client/src/main.rs               |  32 -----
 examples/protobuf/pb_message/Cargo.toml            |  13 --
 examples/protobuf/pb_message/build.rs              |  18 ---
 examples/protobuf/pb_message/src/lib.rs            |  37 ------
 examples/protobuf/pb_message/src/pb/greeter.rs     |  10 --
 examples/protobuf/pb_message/src/pb/mod.rs         |   5 -
 examples/protobuf/server/Cargo.toml                |  10 --
 xds/Cargo.toml                                     |   3 +
 xds/src/error.rs                                   | 136 +++++++++++++++++++++
 xds/src/lib.rs                                     |  17 +++
 xds/src/request.rs                                 | 131 ++++++++++++++++++++
 xds/src/response.rs                                | 131 ++++++++++++++++++++
 xds/src/util.rs                                    |   9 ++
 xds/src/wrapper.rs                                 | 110 +++++++++++++++++
 31 files changed, 893 insertions(+), 143 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 0fe1fd2..3016158 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,12 +1,12 @@
 [workspace]
 members = [
   "xds",
+  "dubbo-build",
   "protocol",
   "registry",
   "metadata",
   "common",
   "config",
-  "examples/protobuf/client",
-  "examples/protobuf/server",
-  "examples/protobuf/pb_message",
+  "examples/grpc-gen",
+  "examples/protobuf-transport",
 ]
\ No newline at end of file
diff --git a/dubbo-build/Cargo.toml b/dubbo-build/Cargo.toml
new file mode 100644
index 0000000..5839555
--- /dev/null
+++ b/dubbo-build/Cargo.toml
@@ -0,0 +1,12 @@
+[package]
+name = "dubbo-build"
+version = "0.1.0"
+edition = "2021"
+
+[features]
+generator-code = ["prost-build"]
+
+
+
+[dependencies]
+prost-build = { version = "0.10.4", optional = true }
\ No newline at end of file
diff --git a/dubbo-build/src/generator.rs b/dubbo-build/src/generator.rs
new file mode 100644
index 0000000..05e25cf
--- /dev/null
+++ b/dubbo-build/src/generator.rs
@@ -0,0 +1,136 @@
+use prost_build::{Method, Service, ServiceGenerator};
+
+#[derive(Default)]
+pub struct CodeGenerator {}
+
+impl CodeGenerator {
+    pub fn new() -> CodeGenerator { Default::default() }
+
+    fn generate_module_name(&self) -> &str { "xds" }
+
+    fn generate_type_aliases(&mut self, buf: &mut String) {
+        buf.push_str(&format!(
+            "\n\
+                pub type DBReq<I> = {0}::request::ServiceRequest<I>;\n\
+                pub type DBResp<O> = Result<{0}::response::ServiceResponse<O>, {0}::error::DBProstError>;\n",
+            self.generate_module_name()));
+    }
+
+    fn generate_main_trait(&self, service: &Service, buf: &mut String) {
+        buf.push_str("\nuse async_trait::async_trait;\n\n#[async_trait]\n");
+
+        service.comments.append_with_indent(0, buf);
+        buf.push_str(&format!("pub trait {} {{", service.name));
+        for method in service.methods.iter() {
+            buf.push_str("\n");
+            method.comments.append_with_indent(1, buf);
+            buf.push_str(&format!("   {};\n", self.method_sig(method)));
+        }
+        buf.push_str("}\n");
+    }
+
+    fn method_sig(&self, method: &Method) -> String {
+        format!("async fn {0}(&self, request: DBReq<{1}>) -> DBResp<{2}>",
+                method.name, method.input_type, method.output_type)
+    }
+
+    fn generate_client_struct(&self, service: &Service, buf: &mut String) {
+        buf.push_str(&format!(
+            "\n\
+            pub struct {0}Client {{\n    \
+                pub hyper_client: {1}::wrapper::HyperClient \n\
+            }}\n",service.name, self.generate_module_name()));
+    }
+
+    fn generate_client_impl(&self, service: &Service, buf: &mut String) {
+        buf.push_str(&format!(
+            "\n\
+            impl {0}Client {{\n     \
+               pub fn new(root_url: &str) -> {0}Client {{\n        \
+                   {0}Client {{\n            \
+                        hyper_client: {1}::wrapper::HyperClient::new(root_url) \n        \
+                   }}\n     \
+               }}\n\
+            }}\n", service.name, self.generate_module_name()));
+
+        buf.push_str("\n#[async_trait]");
+        buf.push_str(&format!("\nimpl {0} for {0}Client {{", service.name));
+
+        for method in service.methods.iter() {
+            buf.push_str(&format!(
+                "\n    {} {{\n        \
+                    self.hyper_client.request(\"/dubbo/{}.{}/{}\", request).await\n    \
+                }}\n", self.method_sig(method), service.package, service.proto_name, method.proto_name));
+        }
+        buf.push_str("}\n");
+    }
+
+    fn generate_server_struct(&self, service: &Service, buf: &mut String) {
+        buf.push_str(&format!(
+            "\n\
+            pub struct {0}Server<T: 'static + {0} + Send + Sync + Clone> {{\n    \
+                pub hyper_server: {1}::wrapper::HyperServer<T> \n\
+            }}\n",service.name, self.generate_module_name()));
+    }
+
+    fn generate_server_impl(&self, service: &Service, buf: &mut String) {
+        buf.push_str(&format!(
+            "\n\
+             impl<T: 'static + {0} + Send + Sync + Clone> {0}Server<T> {{\n    \
+                pub fn new(&self, service: T) -> {0}Server<T> {{\n        \
+                    {0}Server {{\n            \
+                        hyper_server: {1}::wrapper::HyperServer::new(service) \n        \
+                   }}\n     \
+                }}\n\
+            }}\n",
+            service.name, self.generate_module_name()));
+
+        buf.push_str(&format!(
+            "\n\
+            impl<T: 'static + {0} + Send + Sync + Clone> {1}::wrapper::HyperService for {0}Server<T> {{\n    \
+                fn handle(&self, req: DBReq<Vec<u8>>) -> {1}::BoxFutureResp<Vec<u8>> {{\n       \
+                    use ::futures::Future;\n       \
+                    let trait_object_service = self.hyper_server.service.clone();\n       \
+                    match (req.method.clone(), req.uri.path()) {{",
+            service.name, self.generate_module_name()));
+
+        // Make match arms for each type
+        for method in service.methods.iter() {
+            buf.push_str(&format!(
+                "\n          \
+                (::hyper::Method::POST, \"/dubbo/{0}.{1}/{2}\") => {{\n              \
+                    Box::pin(async move {{ \n                  \
+                        let proto_req = req.to_proto().unwrap();  \n                  \
+                        let resp = trait_object_service.{3}(proto_req).await.unwrap();  \n                  \
+                        let proto_resp = resp.to_proto_raw();  \n                  \
+                        proto_resp  \n               \
+                    }}) \n           \
+                 }},", service.package, service.proto_name, method.proto_name, method.name));
+        }
+        // Final 404 arm and end fn
+        buf.push_str(&format!(
+            "\n          \
+                _ => {{\n            \
+                    Box::pin(async move {{ \n                \
+                        Ok({0}::error::DBError::new(::hyper::StatusCode::NOT_FOUND, \"not_found\", \"Not found\").to_resp_raw()) \n            \
+                    }}) \n          \
+                }}\n       \
+            }}\n   \
+            }}\n\
+        }}", self.generate_module_name()));
+    }
+}
+
+impl ServiceGenerator for CodeGenerator {
+    fn generate(&mut self, service: Service, buf: &mut String) {
+        self.generate_type_aliases(buf);
+        self.generate_main_trait(&service, buf);
+        self.generate_client_struct(&service, buf);
+        self.generate_client_impl(&service, buf);
+        self.generate_server_struct(&service, buf);
+        self.generate_server_impl(&service, buf);
+    }
+
+    fn finalize(&mut self, buf: &mut String) {
+    }
+}
diff --git a/dubbo-build/src/lib.rs b/dubbo-build/src/lib.rs
new file mode 100644
index 0000000..329eb39
--- /dev/null
+++ b/dubbo-build/src/lib.rs
@@ -0,0 +1,8 @@
+
+
+#[cfg(feature = "generator-code")]
+extern crate prost_build;
+#[cfg(feature = "generator-code")]
+mod generator;
+#[cfg(feature = "generator-code")]
+pub use generator::CodeGenerator;
diff --git a/examples/grpc-gen/Cargo.toml b/examples/grpc-gen/Cargo.toml
new file mode 100644
index 0000000..335c81c
--- /dev/null
+++ b/examples/grpc-gen/Cargo.toml
@@ -0,0 +1,20 @@
+[package]
+name = "grpc-gen"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+futures = "0.3.21"
+prost = "0.10.4"
+async-trait = { version = "0.1.56" }
+xds = { version = "0.1.0", path = "../../xds" }
+
+hyper = { version = "0.14.19", features = ["full"] }
+
+
+
+[build-dependencies]
+prost-build = "0.10.4"
+dubbo-build = { path = "../../dubbo-build", features = ["generator-code"] }
\ No newline at end of file
diff --git a/examples/grpc-gen/build.rs b/examples/grpc-gen/build.rs
new file mode 100644
index 0000000..0098c18
--- /dev/null
+++ b/examples/grpc-gen/build.rs
@@ -0,0 +1,12 @@
+use std::io::Result;
+use prost_build::Config;
+
+fn main() -> Result<()> {
+    let mut conf = Config::new();
+    let mut gen = dubbo_build::CodeGenerator::new();
+    conf.service_generator(Box::new(gen));
+    conf.out_dir("src/");
+    conf.compile_protos(&["pb/greeter.proto"], &["pb/"]).unwrap();
+
+    Ok(())
+}
\ No newline at end of file
diff --git a/examples/protobuf/pb_message/pb/greeter.proto b/examples/grpc-gen/pb/greeter.proto
similarity index 100%
rename from examples/protobuf/pb_message/pb/greeter.proto
rename to examples/grpc-gen/pb/greeter.proto
diff --git a/examples/grpc-gen/src/greeter.rs b/examples/grpc-gen/src/greeter.rs
new file mode 100644
index 0000000..3ecb8f2
--- /dev/null
+++ b/examples/grpc-gen/src/greeter.rs
@@ -0,0 +1,73 @@
+#[derive(Clone, PartialEq, ::prost::Message)]
+pub struct HelloRequest {
+    #[prost(string, tag="1")]
+    pub name: ::prost::alloc::string::String,
+}
+#[derive(Clone, PartialEq, ::prost::Message)]
+pub struct HelloResponse {
+    #[prost(string, tag="1")]
+    pub message: ::prost::alloc::string::String,
+}
+
+pub type DBReq<I> = xds::request::ServiceRequest<I>;
+pub type DBResp<O> = Result<xds::response::ServiceResponse<O>, xds::error::DBProstError>;
+
+use async_trait::async_trait;
+
+#[async_trait]
+pub trait Greeter {
+   async fn say_hello(&self, request: DBReq<HelloRequest>) -> DBResp<HelloResponse>;
+}
+
+pub struct GreeterClient {
+    pub hyper_client: xds::wrapper::HyperClient 
+}
+
+impl GreeterClient {
+     pub fn new(root_url: &str) -> GreeterClient {
+        GreeterClient {
+            hyper_client: xds::wrapper::HyperClient::new(root_url) 
+        }
+     }
+}
+
+#[async_trait]
+impl Greeter for GreeterClient {
+    async fn say_hello(&self, request: DBReq<HelloRequest>) -> DBResp<HelloResponse> {
+        self.hyper_client.request("/dubbo/greeter.Greeter/SayHello", request).await
+    }
+}
+
+pub struct GreeterServer<T: 'static + Greeter + Send + Sync + Clone> {
+    pub hyper_server: xds::wrapper::HyperServer<T> 
+}
+
+impl<T: 'static + Greeter + Send + Sync + Clone> GreeterServer<T> {
+    pub fn new(&self, service: T) -> GreeterServer<T> {
+        GreeterServer {
+            hyper_server: xds::wrapper::HyperServer::new(service) 
+        }
+     }
+}
+
+impl<T: 'static + Greeter + Send + Sync + Clone> xds::wrapper::HyperService for GreeterServer<T> {
+    fn handle(&self, req: DBReq<Vec<u8>>) -> xds::BoxFutureResp<Vec<u8>> {
+       use ::futures::Future;
+       let trait_object_service = self.hyper_server.service.clone();
+       match (req.method.clone(), req.uri.path()) {
+          (::hyper::Method::POST, "/dubbo/greeter.Greeter/SayHello") => {
+              Box::pin(async move { 
+                  let proto_req = req.to_proto().unwrap();  
+                  let resp = trait_object_service.say_hello(proto_req).await.unwrap();  
+                  let proto_resp = resp.to_proto_raw();  
+                  proto_resp  
+               }) 
+           },
+          _ => {
+            Box::pin(async move { 
+                Ok(xds::error::DBError::new(::hyper::StatusCode::NOT_FOUND, "not_found", "Not found").to_resp_raw()) 
+            }) 
+          }
+       }
+   }
+}
\ No newline at end of file
diff --git a/examples/grpc-gen/src/main.rs b/examples/grpc-gen/src/main.rs
new file mode 100644
index 0000000..68b341a
--- /dev/null
+++ b/examples/grpc-gen/src/main.rs
@@ -0,0 +1,12 @@
+
+mod greeter;
+use greeter::*;
+
+
+fn main() {
+
+    let client =  GreeterClient::new("0.0.0.0:8080");
+    let hello_req = DBReq::new(HelloRequest { name: "johankoi".into()});
+    client.say_hello(hello_req);
+
+}
diff --git a/examples/protobuf-transport/Cargo.toml b/examples/protobuf-transport/Cargo.toml
new file mode 100644
index 0000000..8a35f90
--- /dev/null
+++ b/examples/protobuf-transport/Cargo.toml
@@ -0,0 +1,30 @@
+[package]
+name = "protobuf-transport"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+xds = { version = "0.1.0", path = "../../xds" }
+tokio = {version = "1.9.0", features = ["full"]}
+hyper = { version = "0.14", features = ["full"] }
+futures = "0.3.21"
+prost = "0.10.4"
+
+
+[lib]
+path = "./src/lib.rs"
+
+[[bin]]
+name="server"
+path="./src/server.rs"
+
+[[bin]]
+name="client"
+path="./src/client.rs"
+
+
+[build-dependencies]
+prost-build = "0.10.4"
+dubbo-build = { path = "../../dubbo-build", features = ["generator-code"] }
\ No newline at end of file
diff --git a/examples/protobuf-transport/build.rs b/examples/protobuf-transport/build.rs
new file mode 100644
index 0000000..6459de7
--- /dev/null
+++ b/examples/protobuf-transport/build.rs
@@ -0,0 +1,9 @@
+use std::io::Result;
+use prost_build::Config;
+
+fn main() -> Result<()> {
+    Config::new()
+        .out_dir("src/")
+        .compile_protos(&["pb/person.proto"], &["pb/"])?;
+    Ok(())
+}
\ No newline at end of file
diff --git a/examples/protobuf/pb_message/pb/person.proto b/examples/protobuf-transport/pb/person.proto
similarity index 100%
rename from examples/protobuf/pb_message/pb/person.proto
rename to examples/protobuf-transport/pb/person.proto
diff --git a/examples/protobuf-transport/src/client.rs b/examples/protobuf-transport/src/client.rs
new file mode 100644
index 0000000..4d598bb
--- /dev/null
+++ b/examples/protobuf-transport/src/client.rs
@@ -0,0 +1,33 @@
+use std::collections::hash_map::HashMap;
+use xds::{client::RpcClient};
+use prost::Message;
+use hyper::body::Buf;
+use hyper::{Request, Response};
+
+pub mod person;
+use person::Person;
+
+
+#[tokio::main]
+async fn main() {
+
+    let mut client = RpcClient::new(String::from("http://127.0.0.1:8972"));
+
+    let service_path = String::from("helloworld");
+    let service_method = String::from("hello");
+    let metadata = HashMap::new();
+
+    let mut person = Person::default();
+    person.name = "guomiwu".to_string();
+    let pbData = person.encode_to_vec();
+
+    let callResult = client.call(service_path, service_method, &metadata, pbData).await;
+    let resp = callResult.unwrap();
+
+    //  asynchronously aggregate the chunks of the body
+    let body = hyper::body::aggregate(resp).await;
+    let data = body.unwrap().chunk().to_vec();
+
+    let resPerson = Person::decode(data.as_ref()).unwrap();
+    println!("resPerson={:?}", resPerson.name);
+}
\ No newline at end of file
diff --git a/examples/protobuf-transport/src/lib.rs b/examples/protobuf-transport/src/lib.rs
new file mode 100644
index 0000000..959e687
--- /dev/null
+++ b/examples/protobuf-transport/src/lib.rs
@@ -0,0 +1,7 @@
+
+pub mod person;
+pub use person::*;
+
+fn main() {
+    println!("Hello, world!");
+}
diff --git a/examples/protobuf/pb_message/src/pb/person.rs b/examples/protobuf-transport/src/person.rs
similarity index 100%
rename from examples/protobuf/pb_message/src/pb/person.rs
rename to examples/protobuf-transport/src/person.rs
diff --git a/examples/protobuf/server/src/main.rs b/examples/protobuf-transport/src/server.rs
similarity index 82%
rename from examples/protobuf/server/src/main.rs
rename to examples/protobuf-transport/src/server.rs
index a182144..9b0c443 100644
--- a/examples/protobuf/server/src/main.rs
+++ b/examples/protobuf-transport/src/server.rs
@@ -5,7 +5,7 @@ use xds::{ server::RpcServer };
 #[tokio::main]
 async fn main() {
     let addr = SocketAddr::from(([127, 0, 0, 1], 8972));
-    let mut server = RpcServer::new(addr);
+    let server = RpcServer::new(addr);
     server.start().await;
     println!("RpcServer ok");
 }
\ No newline at end of file
diff --git a/examples/protobuf/client/Cargo.toml b/examples/protobuf/client/Cargo.toml
deleted file mode 100644
index e4c426c..0000000
--- a/examples/protobuf/client/Cargo.toml
+++ /dev/null
@@ -1,14 +0,0 @@
-[package]
-name = "protobuf"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-xds = { version = "0.1.0", path = "../../../xds" }
-tokio = {version = "1.9.0", features = ["full"]}
-pb_message =  { version = "0.1.0", path = "../pb_message" }
-prost = "0.10.4"
-hyper = { version = "0.14", features = ["full"] }
-
diff --git a/examples/protobuf/client/src/main.rs b/examples/protobuf/client/src/main.rs
deleted file mode 100644
index bd6507f..0000000
--- a/examples/protobuf/client/src/main.rs
+++ /dev/null
@@ -1,32 +0,0 @@
-use std::collections::hash_map::HashMap;
-use xds::{ client::RpcClient };
-use pb_message::pb::person::Person;
-use prost::Message;
-use hyper::body::Buf;
-
-#[tokio::main]
-async fn main() {
-    let task = tokio::spawn(async move {
-        let mut client = RpcClient::new(String::from("http://127.0.0.1:8972"));
-
-        let service_path = String::from("helloworld");
-        let service_method = String::from("hello");
-        let metadata = HashMap::new();
-
-        let mut person = Person::default();
-        person.name = "guomiwu".to_string();
-        let pbData = person.encode_to_vec();
-
-        let callResult = client.call(service_path, service_method, &metadata, pbData).await;
-        let resp = callResult.unwrap();
-
-        //  asynchronously aggregate the chunks of the body
-        let body = hyper::body::aggregate(resp).await;
-        let data = body.unwrap().chunk().to_vec();
-
-        let resPerson = Person::decode(data.as_ref()).unwrap();
-        println!("resPerson={:?}", resPerson.name);
-
-    });
-    task.await.unwrap();
-}
\ No newline at end of file
diff --git a/examples/protobuf/pb_message/Cargo.toml b/examples/protobuf/pb_message/Cargo.toml
deleted file mode 100644
index f4a97cd..0000000
--- a/examples/protobuf/pb_message/Cargo.toml
+++ /dev/null
@@ -1,13 +0,0 @@
-[package]
-name = "pb_message"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-prost = "0.10.4"
-prost-types = "0.10.1"
-
-[build-dependencies]
-prost-build = "0.10.4"
\ No newline at end of file
diff --git a/examples/protobuf/pb_message/build.rs b/examples/protobuf/pb_message/build.rs
deleted file mode 100644
index a198077..0000000
--- a/examples/protobuf/pb_message/build.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-use std::io::Result;
-use prost_build::Config;
-
-fn main() -> Result<()> {
-
-    Config::new()
-        .out_dir("src/pb")
-        .compile_protos(&["pb/person.proto"], &["pb/"])?;
-
-    // println!("cargo:rerun-if-changed=pb/greeter_rpc.pb");
-    // println!("cargo:rerun-if-changed=pb/build.rs");
-
-    Config::new()
-        .out_dir("src/pb")
-        .compile_protos(&["pb/greeter.proto"], &["pb/"])?;
-
-    Ok(())
-}
\ No newline at end of file
diff --git a/examples/protobuf/pb_message/src/lib.rs b/examples/protobuf/pb_message/src/lib.rs
deleted file mode 100644
index 3a90aed..0000000
--- a/examples/protobuf/pb_message/src/lib.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-
-pub mod pb;
-
-#[cfg(test)]
-mod tests {
-    use crate::pb::Person;
-    use crate::pb::greeter;
-
-    use std::io::Cursor;
-    use prost::Message;
-
-    pub fn create_hello_request(name: String) -> greeter::HelloRequest {
-        let mut hello_request = greeter::HelloRequest::default();
-        hello_request.name = name;
-        hello_request
-    }
-
-    pub fn serialize_greeter(hello: &greeter::HelloRequest) -> Vec<u8> {
-        let mut buf = Vec::new();
-        buf.reserve(hello.encoded_len());
-
-        hello.encode(&mut buf).unwrap();
-        buf
-    }
-
-
-    // pub fn deserialize_greeter(buf: &[u8]) -> Result<greeter::HelloRequest, prost::DecodeError> {
-    //     greeter::HelloRequest::decode(&mut Cursor::new(buf))
-    // }
-
-    #[test]
-    fn it_works() {
-        let person = Person::default();
-        person.encode_to_vec();
-        println!("{person:?}");
-    }
-}
diff --git a/examples/protobuf/pb_message/src/pb/greeter.rs b/examples/protobuf/pb_message/src/pb/greeter.rs
deleted file mode 100644
index 36aa34d..0000000
--- a/examples/protobuf/pb_message/src/pb/greeter.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-#[derive(Clone, PartialEq, ::prost::Message)]
-pub struct HelloRequest {
-    #[prost(string, tag="1")]
-    pub name: ::prost::alloc::string::String,
-}
-#[derive(Clone, PartialEq, ::prost::Message)]
-pub struct HelloResponse {
-    #[prost(string, tag="1")]
-    pub message: ::prost::alloc::string::String,
-}
diff --git a/examples/protobuf/pb_message/src/pb/mod.rs b/examples/protobuf/pb_message/src/pb/mod.rs
deleted file mode 100644
index 8c11e43..0000000
--- a/examples/protobuf/pb_message/src/pb/mod.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-pub mod person;
-pub mod greeter;
-
-pub use person::*;
-pub use greeter::*;
\ No newline at end of file
diff --git a/examples/protobuf/server/Cargo.toml b/examples/protobuf/server/Cargo.toml
deleted file mode 100644
index fe077e4..0000000
--- a/examples/protobuf/server/Cargo.toml
+++ /dev/null
@@ -1,10 +0,0 @@
-[package]
-name = "server"
-version = "0.1.0"
-edition = "2021"
-
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
-[dependencies]
-xds = { version = "0.1.0", path = "../../../xds" }
-tokio = {version = "1.9.0", features = ["full"]}
\ No newline at end of file
diff --git a/xds/Cargo.toml b/xds/Cargo.toml
index 49af168..f224f7c 100644
--- a/xds/Cargo.toml
+++ b/xds/Cargo.toml
@@ -25,3 +25,6 @@ flate2 = "1.0"
 tower = "0.4"
 log = "0.4"
 env_logger = "0.9.0"
+
+
+prost = "0.10.4"
\ No newline at end of file
diff --git a/xds/src/error.rs b/xds/src/error.rs
new file mode 100644
index 0000000..e212835
--- /dev/null
+++ b/xds/src/error.rs
@@ -0,0 +1,136 @@
+use serde_json;
+use prost::{DecodeError, EncodeError};
+use hyper::{Body, Response, Method, Version, header, StatusCode};
+use crate::response::ServiceResponse;
+
+
+/// A JSON-serializable DBError error
+#[derive(Debug)]
+pub struct DBError {
+    pub status: StatusCode,
+    pub error_type: String,
+    pub msg: String,
+    pub meta: Option<serde_json::Value>,
+}
+
+impl DBError {
+    /// Create a DBError error with no meta
+    pub fn new(status: StatusCode, error_type: &str, msg: &str) -> DBError {
+        DBError::new_meta(status, error_type, msg, None)
+    }
+
+    /// Create a DBError error with optional meta
+    pub fn new_meta(status: StatusCode, error_type: &str, msg: &str, meta: Option<serde_json::Value>) -> DBError {
+        DBError { status, error_type: error_type.to_string(), msg: msg.to_string(), meta }
+    }
+
+    /// Create a byte-array service response for this error and the given status code
+    pub fn to_resp_raw(&self) -> ServiceResponse<Vec<u8>> {
+        let output = self.to_json_bytes().unwrap_or_else(|_| "{}".as_bytes().to_vec());
+        let mut headers = header::HeaderMap::new();
+        headers.insert(header::CONTENT_TYPE, "json".parse().unwrap());
+        let lenth_value = header::HeaderValue::from(output.len() as u64);
+        headers.insert(header::CONTENT_LENGTH, lenth_value);
+
+        ServiceResponse {
+            version: Version::default(),
+            headers,
+            status: self.status,
+            output,
+        }
+    }
+
+    /// Create a hyper response for this error and the given status code
+    pub fn to_hyper_resp(&self) -> Response<Body> {
+        let body = self.to_json_bytes().unwrap_or_else(|_| "{}".as_bytes().to_vec());
+
+        let mut resp = Response::builder()
+            .status(self.status)
+            .body(Body::from(body.clone())).unwrap();
+
+        let header_mut = resp.headers_mut();
+        header_mut.insert(header::CONTENT_TYPE, "json".parse().unwrap());
+        let lenth_value = header::HeaderValue::from(body.len() as u64);
+        header_mut.insert(header::CONTENT_LENGTH, lenth_value);
+        resp
+    }
+
+    /// Create error from Serde JSON value
+    pub fn from_json(status: StatusCode, json: serde_json::Value) -> DBError {
+        let error_type = json["error_type"].as_str();
+        DBError {
+            status,
+            error_type: error_type.unwrap_or("<no code>").to_string(),
+            msg: json["msg"].as_str().unwrap_or("<no message>").to_string(),
+            // Put the whole thing as meta if there was no type
+            meta: if error_type.is_some() { json.get("meta").map(|v| v.clone()) } else { Some(json.clone()) },
+        }
+    }
+
+    /// Create error from byte array
+    pub fn from_json_bytes(status: StatusCode, json: &[u8]) -> serde_json::Result<DBError> {
+        serde_json::from_slice(json).map(|v| DBError::from_json(status, v))
+    }
+
+    /// Create Serde JSON value from error
+    pub fn to_json(&self) -> serde_json::Value {
+        let mut props = serde_json::map::Map::new();
+        props.insert("error_type".to_string(), serde_json::Value::String(self.error_type.clone()));
+        props.insert("msg".to_string(), serde_json::Value::String(self.msg.clone()));
+        if let Some(ref meta) = self.meta { props.insert("meta".to_string(), meta.clone()); }
+        serde_json::Value::Object(props)
+    }
+
+    /// Create byte array from error
+    pub fn to_json_bytes(&self) -> serde_json::Result<Vec<u8>> {
+        serde_json::to_vec(&self.to_json())
+    }
+}
+
+impl From<DBError> for DBProstError {
+    fn from(v: DBError) -> DBProstError { DBProstError::DBWrapError(v) }
+}
+
+
+
+
+
+/// An error that can occur during a call to a  service
+#[derive(Debug)]
+pub enum DBProstError {
+    /// A standard DBError error with a type, message, and some metadata
+    DBWrapError(DBError),
+    /// An error when trying to decode JSON into an error or object
+    JsonDecodeError(serde_json::Error),
+    /// An error when trying to encode a protobuf object
+    ProstEncodeError(EncodeError),
+    /// An error when trying to decode a protobuf object
+    ProstDecodeError(DecodeError),
+    /// A generic hyper error
+    HyperError(hyper::Error),
+    /// A wrapper for any of the other `DBProstError`s that also includes request/response info
+    AfterBodyError {
+        /// The request or response's raw body before the error happened
+        body: Vec<u8>,
+        /// The request method, only present for server errors
+        method: Option<Method>,
+        /// The request or response's HTTP version
+        version: Version,
+        /// The request or response's headers
+        headers: header::HeaderMap,
+        /// The response status, only present for client errors
+        status: Option<StatusCode>,
+        /// The underlying error
+        err: Box<DBProstError>,
+    },
+}
+
+impl DBProstError {
+    /// This same error, or the underlying error if it is an `AfterBodyError`
+    pub fn root_err(self) -> DBProstError {
+        match self {
+            DBProstError::AfterBodyError { err, .. } => err.root_err(),
+            _ => self
+        }
+    }
+}
\ No newline at end of file
diff --git a/xds/src/lib.rs b/xds/src/lib.rs
index 4f818f9..d3a7e94 100644
--- a/xds/src/lib.rs
+++ b/xds/src/lib.rs
@@ -19,6 +19,23 @@ pub mod client;
 pub mod server;
 pub mod protocol;
 
+
+pub mod request;
+pub mod response;
+pub mod wrapper;
+pub mod error;
+pub mod util;
+
+
+
+pub use wrapper::*;
+pub use request::*;
+pub use response::*;
+pub use error::*;
+pub use util::*;
+
+
+
 #[cfg(test)]
 mod tests {
     use crate::client::client::RpcClient;
diff --git a/xds/src/request.rs b/xds/src/request.rs
new file mode 100644
index 0000000..4d497c0
--- /dev/null
+++ b/xds/src/request.rs
@@ -0,0 +1,131 @@
+use hyper::{body, Body, Request, Uri, Method, Version, header};
+use prost::{Message};
+use crate::util::*;
+use crate::error::*;
+
+/// A request with HTTP info and the serialized input object
+#[derive(Debug)]
+pub struct ServiceRequest<T> {
+    /// The URI of the original request
+    ///
+    /// When using a client, this will be overridden with the proper URI. It is only valuable for servers.
+    pub uri: Uri,
+    /// The request method; should always be Post
+    pub method: Method,
+    /// The HTTP version, rarely changed from the default
+    pub version: Version,
+    /// The set of headers
+    ///
+    /// Should always at least have `Content-Type`. Clients will override `Content-Length` on serialization.
+    pub headers: header::HeaderMap,
+    // The serialized request object
+    pub input: T,
+}
+
+impl<T> ServiceRequest<T> {
+    /// Create new service request with the given input object
+    ///
+    /// This automatically sets the `Content-Type` header as `application/protobuf`.
+    pub fn new(input: T) -> ServiceRequest<T> {
+        let mut header = header::HeaderMap::new();
+        header.insert(header::CONTENT_TYPE, "application/protobuf".parse().unwrap());
+        ServiceRequest {
+            uri: Default::default(),
+            method: Method::POST,
+            version: Version::default(),
+            headers: header,
+            input,
+        }
+    }
+
+    /// Copy this request with a different input value
+    pub fn clone_with_input<U>(&self, input: U) -> ServiceRequest<U> {
+        ServiceRequest {
+            uri: self.uri.clone(),
+            method: self.method.clone(),
+            version: self.version,
+            headers: self.headers.clone(),
+            input,
+        }
+    }
+}
+
+impl<T: Message + Default + 'static> From<T> for ServiceRequest<T> {
+    fn from(v: T) -> ServiceRequest<T> { ServiceRequest::new(v) }
+}
+
+impl ServiceRequest<Vec<u8>> {
+    /// Turn a hyper request to a boxed future of a byte-array service request
+    pub fn from_hyper_raw(req: Request<Body>) -> BoxFutureReq<Vec<u8>> {
+        Box::pin(async move {
+            let uri = req.uri().clone();
+            let method = req.method().clone();
+            let version = req.version();
+            let headers = req.headers().clone();
+            let future_req = body::to_bytes(req.into_body()).await
+                .map_err(DBProstError::HyperError)
+                .map(move |body|
+                    ServiceRequest { uri, method, version, headers, input: body.to_vec() }
+                );
+            future_req
+        })
+    }
+
+    /// Turn a byte-array service request into a hyper request
+    pub fn to_hyper_raw(&self) -> Request<Body> {
+        let mut request = Request::builder()
+            .method(self.method.clone())
+            .uri(self.uri.clone())
+            .body(Body::from(self.input.clone())).unwrap();
+
+        let header_mut = request.headers_mut();
+        header_mut.clone_from(&self.headers);
+        let lenth_value = header::HeaderValue::from(self.input.len() as u64);
+        header_mut.insert(header::CONTENT_LENGTH, lenth_value);
+        request
+    }
+
+    /// Turn a byte-array service request into a `AfterBodyError`-wrapped version of the given error
+    pub fn body_err(&self, err: DBProstError) -> DBProstError {
+        DBProstError::AfterBodyError {
+            body: self.input.clone(),
+            method: Some(self.method.clone()),
+            version: self.version,
+            headers: self.headers.clone(),
+            status: None,
+            err: Box::new(err),
+        }
+    }
+
+    /// Serialize the byte-array service request into a protobuf service request
+    pub fn to_proto<T: Message + Default + 'static>(&self) -> Result<ServiceRequest<T>, DBProstError> {
+        match T::decode(self.input.as_ref()) {
+            Ok(v) => Ok(self.clone_with_input(v)),
+            Err(err) => Err(self.body_err(DBProstError::ProstDecodeError(err)))
+        }
+    }
+}
+
+impl<T: Message + Default + 'static> ServiceRequest<T> {
+    /// Turn a protobuf service request into a byte-array service request
+    pub fn to_proto_raw(&self) -> Result<ServiceRequest<Vec<u8>>, DBProstError> {
+        let mut body = Vec::new();
+        if let Err(err) = self.input.encode(&mut body) {
+            Err(DBProstError::ProstEncodeError(err))
+        } else {
+            Ok(self.clone_with_input(body))
+        }
+    }
+
+    /// Turn a hyper request into a protobuf service request
+    pub fn from_hyper_proto(req: Request<Body>) -> BoxFutureReq<T> {
+        Box::pin(async move {
+            ServiceRequest::from_hyper_raw(req).await.and_then(|v| v.to_proto())
+        })
+    }
+
+    /// Turn a protobuf service request into a hyper request
+    pub fn to_hyper_proto(&self) -> Result<Request<Body>, DBProstError> {
+        self.to_proto_raw().map(|v| v.to_hyper_raw())
+    }
+}
\ No newline at end of file
diff --git a/xds/src/response.rs b/xds/src/response.rs
new file mode 100644
index 0000000..b38db8b
--- /dev/null
+++ b/xds/src/response.rs
@@ -0,0 +1,131 @@
+use hyper::{body, Body, Response, Version, header, StatusCode};
+use prost::{Message};
+use crate::util::*;
+use crate::error::*;
+
+
+/// A response with HTTP info and a serialized output object
+#[derive(Debug)]
+pub struct ServiceResponse<T> {
+    /// The HTTP version
+    pub version: Version,
+    /// The set of headers
+    ///
+    /// Should always at least have `Content-Type`. Servers will override `Content-Length` on serialization.
+    pub headers: header::HeaderMap,
+    /// The status code
+    pub status: StatusCode,
+    /// The serialized output object
+    pub output: T,
+}
+
+impl<T> ServiceResponse<T> {
+    /// Create new service request with the given input object
+    ///
+    /// This automatically sets the `Content-Type` header as `application/protobuf`.
+    pub fn new(output: T) -> ServiceResponse<T> {
+        let mut headers = header::HeaderMap::new();
+        headers.insert(header::CONTENT_TYPE, "application/protobuf".parse().unwrap());
+
+        ServiceResponse {
+            version: Version::default(),
+            headers,
+            status: StatusCode::OK,
+            output,
+        }
+    }
+
+    /// Copy this response with a different output value
+    pub fn clone_with_output<U>(&self, output: U) -> ServiceResponse<U> {
+        ServiceResponse { version: self.version, headers: self.headers.clone(), status: self.status, output }
+    }
+}
+
+impl<T: Message + Default + 'static> From<T> for ServiceResponse<T> {
+    fn from(v: T) -> ServiceResponse<T> { ServiceResponse::new(v) }
+}
+
+impl ServiceResponse<Vec<u8>> {
+    /// Turn a hyper response to a boxed future of a byte-array service response
+    pub fn from_hyper_raw(resp: Response<Body>) -> BoxFutureResp<Vec<u8>> {
+        Box::pin(async move {
+            let version = resp.version();
+            let headers = resp.headers().clone();
+            let status = resp.status().clone();
+            let future_resp = body::to_bytes(resp.into_body()).await
+                .map_err(DBProstError::HyperError)
+                .map(move |body|
+                    ServiceResponse { version, headers, status, output: body.to_vec() }
+                );
+            future_resp
+        })
+    }
+
+    /// Turn a byte-array service response into a hyper response
+    pub fn to_hyper_raw(&self) -> Response<Body> {
+        let mut resp = Response::builder()
+            .status(StatusCode::OK)
+            .body(Body::from(self.output.clone())).unwrap();
+
+        let header_mut = resp.headers_mut();
+        header_mut.clone_from(&self.headers);
+        let lenth_value = header::HeaderValue::from(self.output.len() as u64);
+        header_mut.insert(header::CONTENT_LENGTH, lenth_value);
+        resp
+    }
+
+    /// Turn a byte-array service response into a `AfterBodyError`-wrapped version of the given error
+    pub fn body_err(&self, err: DBProstError) -> DBProstError {
+        DBProstError::AfterBodyError {
+            body: self.output.clone(),
+            method: None,
+            version: self.version,
+            headers: self.headers.clone(),
+            status: Some(self.status),
+            err: Box::new(err),
+        }
+    }
+
+
+    /// Serialize the byte-array service response into a protobuf service response
+    pub fn to_proto<T: Message + Default + 'static>(&self) -> Result<ServiceResponse<T>, DBProstError> {
+        if self.status.is_success() {
+            match T::decode(self.output.as_ref()) {
+                Ok(v) => Ok(self.clone_with_output(v)),
+                Err(err) => Err(self.body_err(DBProstError::ProstDecodeError(err)))
+            }
+        } else {
+            match DBError::from_json_bytes(self.status, &self.output) {
+                Ok(err) => Err(self.body_err(DBProstError::DBWrapError(err))),
+                Err(err) => Err(self.body_err(DBProstError::JsonDecodeError(err)))
+            }
+        }
+    }
+}
+
+impl<T: Message + Default + 'static> ServiceResponse<T> {
+    /// Turn a protobuf service response into a byte-array service response
+    pub fn to_proto_raw(&self) -> Result<ServiceResponse<Vec<u8>>, DBProstError> {
+        let mut body = Vec::new();
+        if let Err(err) = self.output.encode(&mut body) {
+            Err(DBProstError::ProstEncodeError(err))
+        } else {
+            Ok(self.clone_with_output(body))
+        }
+    }
+
+
+    /// Turn a hyper response into a protobuf service response
+    pub async fn from_hyper_proto(resp: Response<Body>) -> Result<ServiceResponse<T>, DBProstError> {
+        // Box::pin(async move {
+        ServiceResponse::from_hyper_raw(resp).await.and_then(|v| v.to_proto())
+        // })
+    }
+
+
+    /// Turn a protobuf service response into a hyper response
+    pub fn to_hyper_proto(&self) -> Result<Response<Body>, DBProstError> {
+        self.to_proto_raw().map(|v| v.to_hyper_raw())
+    }
+}
+
diff --git a/xds/src/util.rs b/xds/src/util.rs
new file mode 100644
index 0000000..2fbe3f3
--- /dev/null
+++ b/xds/src/util.rs
@@ -0,0 +1,9 @@
+use futures::future::BoxFuture;
+use crate::request::ServiceRequest;
+use crate::response::ServiceResponse;
+use crate::error::DBProstError;
+
+
+pub type BoxFutureReq<T> = BoxFuture<'static, Result<ServiceRequest<T>, DBProstError>>;
+pub type BoxFutureResp<O> = BoxFuture<'static, Result<ServiceResponse<O>, DBProstError>>;
+
diff --git a/xds/src/wrapper.rs b/xds/src/wrapper.rs
new file mode 100644
index 0000000..b80ffa8
--- /dev/null
+++ b/xds/src/wrapper.rs
@@ -0,0 +1,110 @@
+use std::sync::Arc;
+use std::task::Poll;
+use futures::future::BoxFuture;
+
+use hyper::{Body, Request, Response, header, StatusCode};
+
+use hyper::client::conn::Builder;
+use hyper::client::connect::HttpConnector;
+use hyper::client::service::Connect;
+
+use tower::Service;
+use prost::{Message};
+
+use crate::request::ServiceRequest;
+use crate::response::ServiceResponse;
+use crate::util::*;
+use crate::error::*;
+
+
+
+/// A wrapper for a hyper client
+#[derive(Debug)]
+pub struct HyperClient {
+    /// The hyper client
+    /// The root URL without any path attached
+    pub root_url: String,
+}
+
+impl HyperClient {
+    /// Create a new client wrapper for the given client and root using protobuf
+    pub fn new(root_url: &str) -> HyperClient {
+        HyperClient {
+            root_url: root_url.trim_end_matches('/').to_string(),
+        }
+    }
+
+    // Invoke the given request for the given path and return a boxed future result
+    pub async fn request<I, O>(&self, path: &str, req: ServiceRequest<I>) -> Result<ServiceResponse<O>, DBProstError>
+        where I: Message + Default + 'static, O: Message + Default + 'static {
+        let hyper_req = req.to_hyper_proto().unwrap();
+        let mut hyper_connect = Connect::new(HttpConnector::new(), Builder::new());
+
+        let url_string = format!("{}/{}", self.root_url, path.trim_start_matches('/'));
+        let uri = url_string.parse::<hyper::Uri>().unwrap();
+
+        let mut req_to_send = hyper_connect.call(uri.clone()).await.map_err(DBProstError::HyperError).unwrap();
+
+        let hyper_resp = req_to_send.call(hyper_req).await.map_err(DBProstError::HyperError).unwrap();
+        ServiceResponse::from_hyper_proto(hyper_resp).await
+    }
+}
+
+/// Service for taking a raw service request and returning a boxed future of a raw service response
+pub trait HyperService {
+    /// Accept a raw service request and return a boxed future of a raw service response
+    fn handle(&self, req: ServiceRequest<Vec<u8>>) -> BoxFutureResp<Vec<u8>>;
+}
+
+/// A wrapper for a `HyperService` trait that keeps a `Arc` version of the service
+pub struct HyperServer<T> {
+    /// The `Arc` version of the service
+    ///
+    /// Needed because of [hyper Service lifetimes](https://github.com/tokio-rs/tokio-service/issues/9)
+    pub service: Arc<T>,
+}
+
+impl<T> HyperServer<T> {
+    /// Create a new service wrapper for the given impl
+    pub fn new(service: T) -> HyperServer<T> { HyperServer { service: Arc::new(service) } }
+}
+
+impl<T> Service<Request<Body>> for HyperServer<T>
+    where T: 'static + Send + Sync + HyperService
+{
+    type Response = Response<Body>;
+    type Error = hyper::Error;
+    type Future = BoxFuture<'static, Result<Self::Response, Self::Error>>;
+
+    fn poll_ready(&mut self, cx: &mut std::task::Context<'_>) -> Poll<Result<(), Self::Error>> {
+        Poll::Ready(Ok(()))
+    }
+
+    fn call(&mut self, req: Request<Body>) -> Self::Future {
+        let content_type = req.headers().get(header::CONTENT_TYPE).unwrap().to_str().unwrap();
+        if content_type == "application/protobuf" {
+            Box::pin(async move {
+                let status = StatusCode::UNSUPPORTED_MEDIA_TYPE;
+                Ok(DBError::new(status, "bad_content_type", "Content type must be application/protobuf").to_hyper_resp())
+            })
+        } else {
+            let service = self.service.clone();
+            Box::pin(async move {
+                let request = ServiceRequest::from_hyper_raw(req).await;
+                let resp = service.handle(request.unwrap()).await;
+                resp.map(|v| v.to_hyper_raw())
+                    .or_else(|err| match err.root_err() {
+                        DBProstError::ProstDecodeError(_) =>
+                            Ok(DBError::new(StatusCode::BAD_REQUEST, "protobuf_decode_err", "Invalid protobuf body").
+                                to_hyper_resp()),
+                        DBProstError::DBWrapError(err) =>
+                            Ok(err.to_hyper_resp()),
+                        DBProstError::HyperError(err) =>
+                            Err(err),
+                        _ => Ok(DBError::new(StatusCode::INTERNAL_SERVER_ERROR, "internal_err", "Internal Error").
+                            to_hyper_resp()),
+                    })
+            })
+        }
+    }
+}
\ No newline at end of file


[dubbo-rust] 21/35: feat: client server message

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 13d77d437ac523915cb3c9da45850b025536709e
Author: johankoi <jo...@163.com>
AuthorDate: Tue Jun 14 01:37:53 2022 +0800

    feat: client server message
    
    Signed-off-by: johankoi <jo...@163.com>
---
 Cargo.toml                                   |   2 +
 {xds => examples/protobuf/client}/Cargo.toml |   5 +-
 examples/protobuf/client/src/main.rs         |  17 +
 {xds => examples/protobuf/server}/Cargo.toml |   4 +-
 examples/protobuf/server/src/main.rs         |  11 +
 xds/Cargo.toml                               |  19 ++
 xds/src/client/client.rs                     |  59 ++++
 xds/src/client/mod.rs                        |   4 +
 xds/src/lib.rs                               |  16 +-
 xds/src/protocol/error.rs                    | 189 +++++++++++
 xds/src/protocol/message.rs                  | 468 +++++++++++++++++++++++++++
 xds/src/protocol/mod.rs                      |   6 +
 xds/src/server/mod.rs                        |   4 +
 xds/src/server/server.rs                     |  76 +++++
 14 files changed, 876 insertions(+), 4 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 3720b7d..f73b8c4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,4 +6,6 @@ members = [
   "metadata",
   "common",
   "config",
+  "examples/protobuf/client",
+  "examples/protobuf/server",
 ]
\ No newline at end of file
diff --git a/xds/Cargo.toml b/examples/protobuf/client/Cargo.toml
similarity index 57%
copy from xds/Cargo.toml
copy to examples/protobuf/client/Cargo.toml
index 75e2515..b0bbc6e 100644
--- a/xds/Cargo.toml
+++ b/examples/protobuf/client/Cargo.toml
@@ -1,8 +1,11 @@
 [package]
-name = "xds"
+name = "protobuf"
 version = "0.1.0"
 edition = "2021"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
+xds = { version = "0.1.0", path = "../../../xds" }
+tokio = {version = "1.9.0", features = ["full"]}
+
diff --git a/examples/protobuf/client/src/main.rs b/examples/protobuf/client/src/main.rs
new file mode 100644
index 0000000..0ae5d6a
--- /dev/null
+++ b/examples/protobuf/client/src/main.rs
@@ -0,0 +1,17 @@
+use std::collections::hash_map::HashMap;
+use xds::{ client::RpcClient };
+
+#[tokio::main]
+async fn main() {
+    let task = tokio::spawn(async move {
+        let mut client = RpcClient::new(String::from("http://127.0.0.1:8972"));
+
+        println!("client call begin");
+        let service_path = String::from("helloworld");
+        let service_method = String::from("hello");
+        let metadata = HashMap::new();
+        client.call(service_path, service_method, &metadata).await;
+
+    });
+    task.await.unwrap();
+}
\ No newline at end of file
diff --git a/xds/Cargo.toml b/examples/protobuf/server/Cargo.toml
similarity index 58%
copy from xds/Cargo.toml
copy to examples/protobuf/server/Cargo.toml
index 75e2515..fe077e4 100644
--- a/xds/Cargo.toml
+++ b/examples/protobuf/server/Cargo.toml
@@ -1,8 +1,10 @@
 [package]
-name = "xds"
+name = "server"
 version = "0.1.0"
 edition = "2021"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
+xds = { version = "0.1.0", path = "../../../xds" }
+tokio = {version = "1.9.0", features = ["full"]}
\ No newline at end of file
diff --git a/examples/protobuf/server/src/main.rs b/examples/protobuf/server/src/main.rs
new file mode 100644
index 0000000..a182144
--- /dev/null
+++ b/examples/protobuf/server/src/main.rs
@@ -0,0 +1,11 @@
+use std::net::SocketAddr;
+use xds::{ server::RpcServer };
+
+
+#[tokio::main]
+async fn main() {
+    let addr = SocketAddr::from(([127, 0, 0, 1], 8972));
+    let mut server = RpcServer::new(addr);
+    server.start().await;
+    println!("RpcServer ok");
+}
\ No newline at end of file
diff --git a/xds/Cargo.toml b/xds/Cargo.toml
index 75e2515..49af168 100644
--- a/xds/Cargo.toml
+++ b/xds/Cargo.toml
@@ -6,3 +6,22 @@ edition = "2021"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
+hyper = { version = "0.14", features = ["full"] }
+tokio = {version = "1.9.0", features = ["full"]}
+futures = "0.3.16"
+
+# protocol
+byteorder = "1.3.2"
+strum = "0.21.0"
+strum_macros = "0.21.1"
+num-traits = "0.2.8"
+enum-primitive-derive = "0.1.2"
+serde = { version = "1.0.126",features = ["derive"]}
+serde_json = "1.0.40"
+bytes = "1.0.1"
+flate2 = "1.0"
+
+# server
+tower = "0.4"
+log = "0.4"
+env_logger = "0.9.0"
diff --git a/xds/src/client/client.rs b/xds/src/client/client.rs
index 2944f98..4cad8f3 100644
--- a/xds/src/client/client.rs
+++ b/xds/src/client/client.rs
@@ -14,3 +14,62 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+use hyper::client::conn::Builder;
+use hyper::client::connect::HttpConnector;
+use hyper::client::service::Connect;
+use hyper::service::Service;
+use hyper::{Body, Request};
+
+use crate::protocol::message::*;
+use std::collections::HashMap;
+
+
+pub struct RpcClient {
+    addr: String
+}
+
+impl RpcClient {
+    pub fn new(addr: String) -> RpcClient {
+        RpcClient {
+            addr
+        }
+    }
+
+    pub async fn call(
+        &mut self,
+        service_path: String,
+        service_method: String,
+        metadata: &Metadata
+    ) -> std::result::Result<(), Box<dyn std::error::Error + Send + Sync>>
+    {
+        let mut req = Message::new();
+        req.set_version(0);
+        req.set_message_type(MessageType::Request);
+        req.set_serialize_type(SerializeType::Protobuf);
+        req.set_compress_type(CompressType::Gzip);
+        req.service_path = service_path;
+        req.service_method = service_method;
+
+        let mut new_metadata = HashMap::with_capacity(metadata.len());
+        for (k, v) in metadata {
+            new_metadata.insert(k.clone(), v.clone());
+        }
+        req.metadata.replace(new_metadata);
+        let body_data = req.encode();
+
+        // println!("call, body_data={:?}", body_data);
+
+        let mut mk_svc = Connect::new(HttpConnector::new(), Builder::new());
+        let uri = self.addr.parse::<hyper::Uri>().unwrap();
+        let mut svc = mk_svc.call(uri.clone()).await?;
+
+        let body = Body::from(body_data);
+        let req = Request::get(uri.clone()).body(body)?;
+        let res = svc.call(req).await?;
+        println!("RESPONSE={:?}", res.body());
+
+        Ok(())
+    }
+}
+
diff --git a/xds/src/client/mod.rs b/xds/src/client/mod.rs
index 2944f98..d8d317f 100644
--- a/xds/src/client/mod.rs
+++ b/xds/src/client/mod.rs
@@ -14,3 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+pub(crate) mod client;
+pub use self::client::*;
+
diff --git a/xds/src/lib.rs b/xds/src/lib.rs
index 3e01853..736d111 100644
--- a/xds/src/lib.rs
+++ b/xds/src/lib.rs
@@ -15,11 +15,23 @@
  * limitations under the License.
  */
 
+pub mod client;
+pub mod server;
+mod protocol;
+
 #[cfg(test)]
 mod tests {
+    use crate::client::client::RpcClient;
+    use crate::server::server::RpcServer;
+    use std::net::SocketAddr;
     #[test]
     fn it_works() {
-        let result = 2 + 2;
-        assert_eq!(result, 4);
+        // RpcClient
+        let client = RpcClient::new(String::from("http://127.0.0.1:8972"));
+
+        // RpcServer
+        let addr = SocketAddr::from(([127, 0, 0, 1], 8972));
+        let server = RpcServer::new(addr);
+        println!("it_works");
     }
 }
diff --git a/xds/src/protocol/error.rs b/xds/src/protocol/error.rs
new file mode 100644
index 0000000..c1cdd8f
--- /dev/null
+++ b/xds/src/protocol/error.rs
@@ -0,0 +1,189 @@
+use std::{convert::From, error, fmt, result, str};
+
+pub type Result<T> = result::Result<T, Error>;
+
+pub struct Error {
+    repr: Repr,
+}
+
+impl fmt::Debug for Error {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        fmt::Debug::fmt(&self.repr, f)
+    }
+}
+
+enum Repr {
+    Other(String),
+    Simple(ErrorKind),
+    Custom(Box<Custom>),
+}
+
+#[derive(Debug)]
+struct Custom {
+    kind: ErrorKind,
+    error: Box<dyn error::Error + Send + Sync>,
+}
+
+#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
+pub enum ErrorKind {
+    Protocol,
+    IO,
+    Client,
+    Network,
+    Server,
+    Serialization,
+    Other,
+}
+
+impl ErrorKind {
+    pub(crate) fn as_str(self) -> &'static str {
+        match self {
+            ErrorKind::Protocol => "invalid protocol",
+            ErrorKind::IO => "io issue",
+            ErrorKind::Client => "client error",
+            ErrorKind::Network => "network issue",
+            ErrorKind::Server => "server error",
+            ErrorKind::Serialization => "serialization failure",
+            ErrorKind::Other => "other",
+        }
+    }
+}
+
+impl From<&'static str> for Error {
+    #[inline]
+    fn from(s: &'static str) -> Error {
+        Error {
+            repr: Repr::Other(s.to_owned()),
+        }
+    }
+}
+
+impl From<String> for Error {
+    #[inline]
+    fn from(s: String) -> Error {
+        Error {
+            repr: Repr::Other(s),
+        }
+    }
+}
+
+impl From<serde_json::error::Error> for Error {
+    #[inline]
+    fn from(err: serde_json::error::Error) -> Error {
+        Error::new(ErrorKind::IO, err)
+    }
+}
+
+impl From<std::io::Error> for Error {
+    #[inline]
+    fn from(err: std::io::Error) -> Error {
+        Error::new(ErrorKind::IO, err)
+    }
+}
+
+impl From<Box<dyn std::error::Error + Send + Sync>> for Error {
+    #[inline]
+    fn from(err: Box<dyn std::error::Error + Send + Sync>) -> Error {
+        Error::_new(ErrorKind::Other, err)
+    }
+}
+impl From<ErrorKind> for Error {
+    #[inline]
+    fn from(kind: ErrorKind) -> Error {
+        Error {
+            repr: Repr::Simple(kind),
+        }
+    }
+}
+
+impl Error {
+    pub fn new<E>(kind: ErrorKind, error: E) -> Error
+    where
+        E: Into<Box<dyn error::Error + Send + Sync>>,
+    {
+        Self::_new(kind, error.into())
+    }
+
+    fn _new(kind: ErrorKind, error: Box<dyn error::Error + Send + Sync>) -> Error {
+        Error {
+            repr: Repr::Custom(Box::new(Custom { kind, error })),
+        }
+    }
+
+    pub fn get_ref(&self) -> Option<&(dyn error::Error + Send + Sync + 'static)> {
+        match self.repr {
+            Repr::Other(..) => None,
+            Repr::Simple(..) => None,
+            Repr::Custom(ref c) => Some(&*c.error),
+        }
+    }
+
+    pub fn get_mut(&mut self) -> Option<&mut (dyn error::Error + Send + Sync + 'static)> {
+        match self.repr {
+            Repr::Other(..) => None,
+            Repr::Simple(..) => None,
+            Repr::Custom(ref mut c) => Some(&mut *c.error),
+        }
+    }
+
+    pub fn into_inner(self) -> Option<Box<dyn error::Error + Send + Sync>> {
+        match self.repr {
+            Repr::Other(..) => None,
+            Repr::Simple(..) => None,
+            Repr::Custom(c) => Some(c.error),
+        }
+    }
+
+    pub fn kind(&self) -> ErrorKind {
+        match self.repr {
+            Repr::Other(_) => ErrorKind::Other,
+            Repr::Custom(ref c) => c.kind,
+            Repr::Simple(kind) => kind,
+        }
+    }
+}
+
+impl fmt::Debug for Repr {
+    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
+        match &*self {
+            Repr::Other(s) => write!(fmt, "{}", s),
+            Repr::Custom(ref c) => fmt::Debug::fmt(&c, fmt),
+            Repr::Simple(kind) => fmt.debug_tuple("Kind").field(&kind).finish(),
+        }
+    }
+}
+
+impl fmt::Display for Error {
+    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
+        match &self.repr {
+            Repr::Other(s) => write!(fmt, "{}", s),
+            Repr::Custom(ref c) => c.error.fmt(fmt),
+            Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()),
+        }
+    }
+}
+
+impl error::Error for Error {
+    fn description(&self) -> &str {
+        match &self.repr {
+            Repr::Other(s) => &s[..],
+            Repr::Simple(..) => self.kind().as_str(),
+            Repr::Custom(ref c) => c.error.description(),
+        }
+    }
+
+    fn cause(&self) -> Option<&dyn error::Error> {
+        match self.repr {
+            Repr::Other(..) => None,
+            Repr::Simple(..) => None,
+            Repr::Custom(ref c) => c.error.source(),
+        }
+    }
+    fn source(&self) -> Option<&(dyn error::Error + 'static)> {
+        match self.repr {
+            Repr::Other(..) => None,
+            Repr::Simple(..) => None,
+            Repr::Custom(ref c) => c.error.source(),
+        }
+    }
+}
diff --git a/xds/src/protocol/message.rs b/xds/src/protocol/message.rs
new file mode 100644
index 0000000..1895172
--- /dev/null
+++ b/xds/src/protocol/message.rs
@@ -0,0 +1,468 @@
+use byteorder::{BigEndian, ByteOrder};
+use enum_primitive_derive::Primitive;
+use flate2::{read::GzDecoder, write::GzEncoder, Compression};
+use num_traits::{FromPrimitive, ToPrimitive};
+use strum_macros::{Display, EnumIter, EnumString};
+
+use std::{
+    cell::RefCell,
+    collections::hash_map::HashMap,
+    io::{Read, Write},
+};
+
+use super::error::*;
+
+
+const MAGIC_NUMBER: u8 = 0x08;
+pub const SERVICE_ERROR: &str = "__rpcx_error__";
+
+#[derive(Debug, Copy, Clone, Display, PartialEq, EnumIter, EnumString, Primitive)]
+pub enum MessageType {
+    Request = 0,
+    Response = 1,
+}
+
+#[derive(Debug, Copy, Clone, Display, PartialEq, EnumIter, EnumString, Primitive)]
+pub enum MessageStatusType {
+    Normal = 0,
+    Error = 1,
+}
+
+#[derive(Debug, Copy, Clone, Display, PartialEq, EnumIter, EnumString, Primitive)]
+pub enum CompressType {
+    CompressNone = 0,
+    Gzip = 1,
+}
+
+#[derive(Debug, Copy, Clone, Display, PartialEq, EnumIter, EnumString, Primitive)]
+pub enum SerializeType {
+    SerializeNone = 0,
+    JSON = 1,
+    Protobuf = 2,
+    MsgPack = 3,
+    Thrift = 4,
+}
+
+/// define the rpcx message interface.
+pub trait RpcxMessage {
+    fn check_magic_number(&self) -> bool;
+    fn get_version(&self) -> u8;
+    fn set_version(&mut self, v: u8);
+    fn get_message_type(&self) -> Option<MessageType>;
+    fn set_message_type(&mut self, mt: MessageType);
+    fn is_heartbeat(&self) -> bool;
+    fn set_heartbeat(&mut self, b: bool);
+    fn is_oneway(&self) -> bool;
+    fn set_oneway(&mut self, b: bool);
+    fn get_compress_type(&self) -> Option<CompressType>;
+    fn set_compress_type(&mut self, ct: CompressType);
+    fn get_message_status_type(&self) -> Option<MessageStatusType>;
+    fn set_message_status_type(&mut self, mst: MessageStatusType);
+    fn get_serialize_type(&self) -> Option<SerializeType>;
+    fn set_serialize_type(&mut self, st: SerializeType);
+    fn get_seq(&self) -> u64;
+    fn set_seq(&mut self, seq: u64);
+    fn decode<R: ?Sized>(&mut self, r: &mut R) -> Result<()>
+    where
+        R: Read;
+    fn encode(&self) -> Vec<u8>;
+
+    fn get_error(&self) -> Option<String>;
+}
+
+pub type Metadata = HashMap<String, String>;
+
+/// a commmon struct for request and response.
+#[derive(Debug, Default)]
+pub struct Message {
+    pub header: [u8; 12],
+    pub service_path: String,
+    pub service_method: String,
+    pub metadata: RefCell<Metadata>,
+    pub payload: Vec<u8>,
+}
+impl Message {
+    /// Creates a new `Message`
+    pub fn new() -> Self {
+        let mut msg: Message = Default::default();
+        msg.header = [0u8; 12];
+        msg.header[0] = MAGIC_NUMBER;
+        msg.metadata = RefCell::new(HashMap::new());
+        msg
+    }
+
+    pub fn get_reply(&self) -> Result<Self> {
+        let mut reply = Message::new();
+        reply.set_version(self.get_version());
+        reply.set_compress_type(self.get_compress_type().unwrap());
+        reply.set_message_status_type(MessageStatusType::Normal);
+        reply.set_message_type(MessageType::Response);
+        reply.set_serialize_type(self.get_serialize_type().unwrap());
+        reply.set_seq(self.get_seq());
+        reply.service_path = self.service_path.clone();
+        reply.service_method = self.service_method.clone();
+
+        Ok(reply)
+    }
+}
+
+impl RpcxMessage for Message {
+    fn check_magic_number(&self) -> bool {
+        self.header[0] == MAGIC_NUMBER
+    }
+
+    fn get_version(&self) -> u8 {
+        self.header[1]
+    }
+    fn set_version(&mut self, v: u8) {
+        self.header[1] = v;
+    }
+
+    fn get_message_type(&self) -> Option<MessageType> {
+        MessageType::from_u8((self.header[2] & 0x80) >> 7 as u8)
+    }
+    fn set_message_type(&mut self, mt: MessageType) {
+        self.header[2] |= mt.to_u8().unwrap() << 7;
+    }
+    fn is_heartbeat(&self) -> bool {
+        self.header[2] & 0x40 == 0x40
+    }
+    fn set_heartbeat(&mut self, b: bool) {
+        if b {
+            self.header[2] |= 0x40;
+        } else {
+            self.header[2] &= !0x40;
+        }
+    }
+    fn is_oneway(&self) -> bool {
+        self.header[2] & 0x20 == 0x20
+    }
+    fn set_oneway(&mut self, b: bool) {
+        if b {
+            self.header[2] |= 0x20;
+        } else {
+            self.header[2] &= !0x20;
+        }
+    }
+    fn get_compress_type(&self) -> Option<CompressType> {
+        CompressType::from_u8((self.header[2] & 0x1C) >> 2)
+    }
+    fn set_compress_type(&mut self, ct: CompressType) {
+        self.header[2] = (self.header[2] & !0x1C) | (ct.to_u8().unwrap() << 2 & 0x1C);
+    }
+    fn get_message_status_type(&self) -> Option<MessageStatusType> {
+        MessageStatusType::from_u8(self.header[2] & 0x03)
+    }
+    fn set_message_status_type(&mut self, mst: MessageStatusType) {
+        self.header[2] = (self.header[2] & !0x03) | (mst.to_u8().unwrap() & 0x03);
+    }
+    fn get_serialize_type(&self) -> Option<SerializeType> {
+        SerializeType::from_u8((self.header[3] & 0xF0) >> 4)
+    }
+    fn set_serialize_type(&mut self, st: SerializeType) {
+        self.header[3] = (self.header[3] & !0xF0) | (st.to_u8().unwrap() << 4)
+    }
+    fn get_seq(&self) -> u64 {
+        u64_from_slice(&(self.header[4..]))
+    }
+    fn set_seq(&mut self, seq: u64) {
+        u64_to_slice(seq, &mut self.header[4..]);
+    }
+
+    fn decode<R: ?Sized>(&mut self, r: &mut R) -> Result<()>
+    where
+        R: Read,
+    {
+        r.read_exact(&mut self.header)?;
+
+        let mut buf = [0u8; 4];
+        r.read(&mut buf[..]).map(|_| {})?;
+        let len = BigEndian::read_u32(&buf); //length of all expect header
+        let mut buf = vec![0u8; len as usize];
+        r.read(&mut buf[..]).map(|_| ())?;
+
+        let mut start = 0;
+        // read service_path
+        let len = read_len(&buf[start..(start + 4)]) as usize;
+        let service_path = read_str(&buf[(start + 4)..(start + 4 + len)])?;
+        self.service_path = service_path;
+        start = start + 4 + len;
+        // read service_method
+        let len = read_len(&buf[start..(start + 4)]) as usize;
+        let service_method = read_str(&buf[(start + 4)..(start + 4 + len)])?;
+        self.service_method = service_method;
+
+        start = start + 4 + len;
+        //metadata
+        let len = read_len(&buf[start..(start + 4)]) as usize;
+        let metadata_bytes = &buf[(start + 4)..(start + 4 + len)];
+        let mut meta_start = 0;
+        while meta_start < len {
+            let sl = read_len(&metadata_bytes[meta_start..(meta_start + 4)]) as usize;
+            let key = read_str(&metadata_bytes[(meta_start + 4)..(meta_start + 4 + sl)])?;
+            meta_start = meta_start + 4 + sl;
+            if meta_start < len {
+                let value_len = read_len(&metadata_bytes[meta_start..(meta_start + 4)]) as usize;
+                let value =
+                    read_str(&metadata_bytes[(meta_start + 4)..(meta_start + 4 + value_len)])?;
+                self.metadata.borrow_mut().insert(key, value);
+                meta_start = meta_start + 4 + value_len;
+            } else {
+                self.metadata.borrow_mut().insert(key, String::new());
+                break;
+            }
+        }
+        start = start + 4 + len;
+        // payload
+        let len = read_len(&buf[start..start + 4]) as usize;
+        let payload = &buf[start + 4..];
+        if len != payload.len() {
+            return Err(Error::from("invalid payload length"));
+        }
+
+        let mut vp = Vec::with_capacity(payload.len());
+        match self.get_compress_type().unwrap() {
+            CompressType::Gzip => {
+                let mut deflater = GzDecoder::new(payload);
+                deflater.read_to_end(&mut vp)?;
+            }
+            CompressType::CompressNone => {
+                vp.extend_from_slice(&payload);
+            }
+        }
+        self.payload = vp;
+
+        Ok(())
+    }
+
+    fn encode(&self) -> Vec<u8> {
+        // encode all except header
+        let mut buf = Vec::<u8>::with_capacity(20);
+        buf.extend_from_slice(&self.header);
+
+        // push fake length
+        let len_bytes = write_len(0);
+        buf.extend_from_slice(&len_bytes);
+
+        // service_path
+        let len = self.service_path.len();
+        let len_bytes = write_len(len as u32);
+        buf.extend_from_slice(&len_bytes);
+        buf.extend_from_slice(self.service_path.as_bytes());
+
+        // service_method
+        let len = self.service_method.len();
+        let len_bytes = write_len(len as u32);
+        buf.extend_from_slice(&len_bytes);
+        buf.extend_from_slice(self.service_method.as_bytes());
+
+        // metadata
+        let mut metadata_bytes = Vec::<u8>::new();
+        let metadata = self.metadata.borrow_mut();
+        for meta in metadata.iter() {
+            let key = meta.0;
+            let len_bytes = write_len(key.len() as u32);
+            metadata_bytes.extend_from_slice(&len_bytes);
+            metadata_bytes.extend_from_slice(key.as_bytes());
+
+            let value = meta.1;
+            let len_bytes = write_len(value.len() as u32);
+            metadata_bytes.extend_from_slice(&len_bytes);
+            metadata_bytes.extend_from_slice(value.as_bytes());
+        }
+        let len = metadata_bytes.len();
+        let len_bytes = write_len(len as u32);
+        buf.extend_from_slice(&len_bytes);
+        buf.append(&mut metadata_bytes);
+
+        // data
+        // check compress
+
+        match self.get_compress_type().unwrap() {
+            CompressType::Gzip => {
+                let mut e = GzEncoder::new(Vec::new(), Compression::fast());
+                let _ = e.write_all(&self.payload[..]);
+                let compressed_payload = e.finish().unwrap();
+                let len = compressed_payload.len();
+                let len_bytes = write_len(len as u32);
+                buf.extend_from_slice(&len_bytes);
+                buf.extend_from_slice(&compressed_payload);
+            }
+            _ => {
+                let len = self.payload.len();
+                let len_bytes = write_len(len as u32);
+                buf.extend_from_slice(&len_bytes);
+                buf.extend_from_slice(&self.payload);
+            }
+        }
+
+        // set the real length
+        let len = buf.len() - 12 - 4;
+        let len_bytes = write_len(len as u32);
+        buf[12] = len_bytes[0];
+        buf[13] = len_bytes[1];
+        buf[14] = len_bytes[2];
+        buf[15] = len_bytes[3];
+
+        buf
+    }
+
+    fn get_error(&self) -> Option<String> {
+        match self.get_message_status_type() {
+            Some(MessageStatusType::Error) => {
+                let metadata = &self.metadata;
+                let metadata2 = metadata.borrow();
+                let err_msg = metadata2.get(&SERVICE_ERROR.to_owned())?;
+                Some(String::from(err_msg))
+            }
+            _ => None,
+        }
+    }
+}
+
+fn read_len(buf: &[u8]) -> u32 {
+    BigEndian::read_u32(&buf[..4])
+}
+
+fn write_len(len: u32) -> [u8; 4] {
+    let mut buf = [0u8; 4];
+    BigEndian::write_u32(&mut buf, len);
+    buf
+}
+
+fn read_str(buf: &[u8]) -> Result<String> {
+    let s = std::str::from_utf8(&buf).unwrap();
+    let str: String = std::string::String::from(s);
+    Ok(str)
+}
+
+fn u64_from_slice(b: &[u8]) -> u64 {
+    BigEndian::read_u64(b)
+}
+
+fn u64_to_slice(v: u64, b: &mut [u8]) {
+    BigEndian::write_u64(b, v);
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn parse_header() {
+        let msg_data: Vec<u8> = vec![
+            8, 0, 0, 16, 0, 0, 0, 0, 73, 150, 2, 210, 0, 0, 0, 98, 0, 0, 0, 5, 65, 114, 105, 116,
+            104, 0, 0, 0, 3, 65, 100, 100, 0, 0, 0, 48, 0, 0, 0, 4, 95, 95, 73, 68, 0, 0, 0, 36,
+            54, 98, 97, 55, 98, 56, 49, 48, 45, 57, 100, 97, 100, 45, 49, 49, 100, 49, 45, 56, 48,
+            98, 52, 45, 48, 48, 99, 48, 52, 102, 100, 52, 51, 48, 99, 57, 0, 0, 0, 26, 123, 10, 9,
+            9, 34, 65, 34, 58, 32, 49, 44, 10, 9, 9, 34, 66, 34, 58, 32, 50, 44, 10, 9, 125, 10, 9,
+        ];
+
+        let mut msg = Message::new();
+        (&mut msg.header).copy_from_slice(&msg_data[..12]);
+
+        assert_eq!(true, msg.check_magic_number());
+        assert_eq!(0, msg.get_version());
+        assert_eq!(MessageType::Request, msg.get_message_type().unwrap());
+        assert_eq!(false, msg.is_heartbeat());
+        assert_eq!(false, msg.is_oneway());
+        assert_eq!(CompressType::CompressNone, msg.get_compress_type().unwrap());
+        assert_eq!(
+            MessageStatusType::Normal,
+            msg.get_message_status_type().unwrap()
+        );
+        assert_eq!(SerializeType::JSON, msg.get_serialize_type().unwrap());
+        assert_eq!(1234567890, msg.get_seq());
+    }
+
+    #[test]
+    fn set_header() {
+        let msg_data: Vec<u8> = vec![
+            8, 0, 0, 16, 0, 0, 0, 0, 73, 150, 2, 210, 0, 0, 0, 98, 0, 0, 0, 5, 65, 114, 105, 116,
+            104, 0, 0, 0, 3, 65, 100, 100, 0, 0, 0, 48, 0, 0, 0, 4, 95, 95, 73, 68, 0, 0, 0, 36,
+            54, 98, 97, 55, 98, 56, 49, 48, 45, 57, 100, 97, 100, 45, 49, 49, 100, 49, 45, 56, 48,
+            98, 52, 45, 48, 48, 99, 48, 52, 102, 100, 52, 51, 48, 99, 57, 0, 0, 0, 26, 123, 10, 9,
+            9, 34, 65, 34, 58, 32, 49, 44, 10, 9, 9, 34, 66, 34, 58, 32, 50, 44, 10, 9, 125, 10, 9,
+        ];
+
+        let mut msg = Message::new();
+        msg.header.copy_from_slice(&msg_data[..12]);
+
+        msg.set_version(0);
+        msg.set_message_type(MessageType::Response);
+        msg.set_heartbeat(true);
+        msg.set_oneway(true);
+        msg.set_compress_type(CompressType::Gzip);
+        msg.set_serialize_type(SerializeType::MsgPack);
+        msg.set_message_status_type(MessageStatusType::Normal);
+        msg.set_seq(1000000);
+
+        assert_eq!(true, msg.check_magic_number());
+        assert_eq!(0, msg.get_version());
+        assert_eq!(MessageType::Response, msg.get_message_type().unwrap());
+        assert_eq!(true, msg.is_heartbeat());
+        assert_eq!(true, msg.is_oneway());
+        assert_eq!(CompressType::Gzip, msg.get_compress_type().unwrap());
+        assert_eq!(
+            MessageStatusType::Normal,
+            msg.get_message_status_type().unwrap()
+        );
+        assert_eq!(SerializeType::MsgPack, msg.get_serialize_type().unwrap());
+        assert_eq!(1000000, msg.get_seq());
+    }
+
+    #[test]
+    fn decode() {
+        let msg_data: [u8; 114] = [
+            8, 0, 0, 16, 0, 0, 0, 0, 73, 150, 2, 210, 0, 0, 0, 98, 0, 0, 0, 5, 65, 114, 105, 116,
+            104, 0, 0, 0, 3, 65, 100, 100, 0, 0, 0, 48, 0, 0, 0, 4, 95, 95, 73, 68, 0, 0, 0, 36,
+            54, 98, 97, 55, 98, 56, 49, 48, 45, 57, 100, 97, 100, 45, 49, 49, 100, 49, 45, 56, 48,
+            98, 52, 45, 48, 48, 99, 48, 52, 102, 100, 52, 51, 48, 99, 57, 0, 0, 0, 26, 123, 10, 9,
+            9, 34, 65, 34, 58, 32, 49, 44, 10, 9, 9, 34, 66, 34, 58, 32, 50, 44, 10, 9, 125, 10, 9,
+        ];
+
+        let mut msg = Message::new();
+
+        let mut data = &msg_data[..] as &[u8];
+        match msg.decode(&mut data) {
+            Err(err) => println!("failed to parse: {}", err),
+            Ok(()) => {}
+        }
+
+        assert_eq!("Arith", msg.service_path);
+        assert_eq!("Add", msg.service_method);
+
+        assert_eq!(
+            "6ba7b810-9dad-11d1-80b4-00c04fd430c9",
+            msg.metadata.borrow().get("__ID").unwrap()
+        );
+
+        assert_eq!(
+            "{\n\t\t\"A\": 1,\n\t\t\"B\": 2,\n\t}\n\t",
+            std::str::from_utf8(&msg.payload).unwrap()
+        );
+    }
+
+    #[test]
+    fn encode() {
+        let msg_data: [u8; 114] = [
+            8, 0, 0, 16, 0, 0, 0, 0, 73, 150, 2, 210, 0, 0, 0, 98, 0, 0, 0, 5, 65, 114, 105, 116,
+            104, 0, 0, 0, 3, 65, 100, 100, 0, 0, 0, 48, 0, 0, 0, 4, 95, 95, 73, 68, 0, 0, 0, 36,
+            54, 98, 97, 55, 98, 56, 49, 48, 45, 57, 100, 97, 100, 45, 49, 49, 100, 49, 45, 56, 48,
+            98, 52, 45, 48, 48, 99, 48, 52, 102, 100, 52, 51, 48, 99, 57, 0, 0, 0, 26, 123, 10, 9,
+            9, 34, 65, 34, 58, 32, 49, 44, 10, 9, 9, 34, 66, 34, 58, 32, 50, 44, 10, 9, 125, 10, 9,
+        ];
+
+        let mut msg = Message::new();
+
+        let mut data = &msg_data[..] as &[u8];
+        match msg.decode(&mut data) {
+            Err(err) => println!("failed to parse: {}", err),
+            Ok(()) => {}
+        }
+
+        let encoded_bytes = msg.encode();
+
+        assert_eq!(&msg_data[..], &encoded_bytes[..]);
+    }
+}
diff --git a/xds/src/protocol/mod.rs b/xds/src/protocol/mod.rs
new file mode 100644
index 0000000..1d650a8
--- /dev/null
+++ b/xds/src/protocol/mod.rs
@@ -0,0 +1,6 @@
+pub mod error;
+pub mod message;
+
+
+pub use message::*;
+pub use error::*;
\ No newline at end of file
diff --git a/xds/src/server/mod.rs b/xds/src/server/mod.rs
index 2944f98..f7d8248 100644
--- a/xds/src/server/mod.rs
+++ b/xds/src/server/mod.rs
@@ -14,3 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+pub(crate) mod server;
+pub use self::server::*;
+
diff --git a/xds/src/server/server.rs b/xds/src/server/server.rs
index 2944f98..be343fb 100644
--- a/xds/src/server/server.rs
+++ b/xds/src/server/server.rs
@@ -14,3 +14,79 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+use std::convert::Infallible;
+use std::env;
+use std::process::Output;
+use std::task::Poll;
+use hyper::client::service;
+use hyper::{Body, Request, Response, Server as hyper_server};
+use hyper::service::{make_service_fn, service_fn};
+use tower::Service;
+use futures::future::{ ready, Ready, BoxFuture};
+use std::net::SocketAddr;
+use crate::protocol::message::*;
+
+pub struct RpcServer {
+    pub addr: SocketAddr
+}
+
+impl RpcServer {
+    pub fn new(addr: SocketAddr) -> Self {
+        RpcServer {
+            addr
+        }
+    }
+
+    pub async fn start(&self) {
+        env_logger::init();
+        let make_service = make_service_fn(|_conn| async {
+            let svc = RPCHandler;
+            Ok::<_, Infallible>(svc)
+        });
+
+        let server = hyper_server::bind(&self.addr).serve(make_service);
+        println!("Listening on http://{}", self.addr);
+        if let Err(e) = server.await {
+            eprintln!("server error: {}", e);
+        }
+    }
+}
+
+
+#[derive(Copy, Clone)]
+struct RPCHandler;
+use std::result::Result as StdResult;
+
+impl Service<Request<Body>> for RPCHandler {
+    type Response = Response<Body>;
+    type Error = Infallible;
+    type Future = BoxFuture<'static, StdResult<Self::Response, Self::Error>>;
+
+    fn poll_ready(&mut self, cx: &mut std::task::Context<'_>) -> std::task::Poll<StdResult<(), Self::Error>> {
+        Poll::Ready(Ok(()))
+    }
+
+    fn call(&mut self, req: Request<Body>) -> Self::Future {
+        Box::pin(async move {
+            let whole_body = hyper::body::to_bytes(req.into_body()).await.unwrap();
+
+            let mut msg = Message::new();
+            let mut data = &whole_body[..];
+
+            match msg.decode(&mut data) {
+                Ok(()) => {
+                    let service_path = &msg.service_path;
+                    let service_method = &msg.service_method;
+                    let key = format!("{}.{}", service_path, service_method);
+                    println!("recieved request success, and body message decode key is: {:?}", key);
+                }
+                Err(err) => {
+                    eprintln!("failed to read: {}", err.to_string());
+                }
+            }
+            let resp = ready(Ok(Response::new(Body::from("hello world with tower service! \n")))).await;
+            resp
+        })
+    }
+}


[dubbo-rust] 33/35: Delete .DS_Store

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 7f014c445e21ffe2e6bba523899ef31973209878
Author: Johankoi <Jo...@163.com>
AuthorDate: Thu Jul 21 21:13:37 2022 +0800

    Delete .DS_Store
---
 xds/.DS_Store | Bin 6148 -> 0 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/xds/.DS_Store b/xds/.DS_Store
deleted file mode 100644
index b8d457d..0000000
Binary files a/xds/.DS_Store and /dev/null differ


[dubbo-rust] 31/35: Update client.rs

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 0a38b4ceabd6c8cdbbf237561d71985b1582b2e3
Author: Johankoi <Jo...@163.com>
AuthorDate: Thu Jul 21 17:17:59 2022 +0800

    Update client.rs
    
    port modifiy
---
 examples/protobuf-transport/src/client.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/examples/protobuf-transport/src/client.rs b/examples/protobuf-transport/src/client.rs
index 4d598bb..fe29589 100644
--- a/examples/protobuf-transport/src/client.rs
+++ b/examples/protobuf-transport/src/client.rs
@@ -11,7 +11,7 @@ use person::Person;
 #[tokio::main]
 async fn main() {
 
-    let mut client = RpcClient::new(String::from("http://127.0.0.1:8972"));
+    let mut client = RpcClient::new(String::from("http://127.0.0.1:8975"));
 
     let service_path = String::from("helloworld");
     let service_method = String::from("hello");
@@ -30,4 +30,4 @@ async fn main() {
 
     let resPerson = Person::decode(data.as_ref()).unwrap();
     println!("resPerson={:?}", resPerson.name);
-}
\ No newline at end of file
+}


[dubbo-rust] 26/35: update

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 3a64825ad6769061e6a73ed9bcef2379eb5e3a04
Author: Johankoi <Jo...@163.com>
AuthorDate: Thu Jul 14 12:03:37 2022 +0800

    update
---
 README_CN.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README_CN.md b/README_CN.md
index 99456e3..8b0a573 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -23,8 +23,8 @@ Examples can be found in [`examples`]
 
 ### Tutorials
 
-- The [`protobuf-transport`][protobuf-transport] example provides a basic example for testing transport protobuf-message-object-data via HTTP/2.
-- The [`grpc-gen`][grpc-gen] example provides a complete example of using bubbo-rust client/server grpc.
+- The [`protobuf-transport`] example provides a basic example for testing transport protobuf-message-object-data via HTTP/2.
+- The [`grpc-gen`] example provides a complete example of using bubbo-rust client/server grpc.
 
 ### Contribution
 


[dubbo-rust] 09/35: Create CI.yml

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 949b5f53af57349c927c709f897821fe8397baf4
Author: Johankoi <Jo...@163.com>
AuthorDate: Wed Apr 27 00:26:16 2022 +0800

    Create CI.yml
    
    add workflow
---
 .github/workflows/CI.yml | 56 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
new file mode 100644
index 0000000..993dbd7
--- /dev/null
+++ b/.github/workflows/CI.yml
@@ -0,0 +1,56 @@
+# This is a basic workflow to help you get started with Actions
+
+name: CI
+
+on:
+  push:
+    branches: [ main ]
+  pull_request:
+    branches: [ main ]
+
+  workflow_dispatch:
+
+jobs:
+ check:
+    name: check dubbo-rus project
+    runs-on: ${{ matrix.os }}
+    strategy:
+      matrix:
+        os: [ubuntu-latest, macOS-latest, windows-latest]
+        rust: [stable]
+
+    env:
+      RUSTFLAGS: "-D warnings"
+      
+    steps:
+    - uses: actions/checkout@main
+    - uses: actions-rs/toolchain@v1
+      with:
+          toolchain: ${{ matrix.rust }}
+    - run: cargo che
+    
+ fmt:
+    name: Rustfmt
+    runs-on: ${{ matrix.os }}
+    strategy:
+      matrix:
+        os: [ubuntu-latest, macOS-latest, windows-latest]
+        rust: [stable]
+        
+    steps:
+      - uses: actions/checkout@main
+      - uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: stable
+          override: true
+      - run: rustup component add rustfmt
+      - run: cargo fmt --all -- --check
+      
+  
+
+    
+
+
+   
+   


[dubbo-rust] 27/35: update

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 8f07dad5b365e7c87913f27eee59c57df667f856
Author: Johankoi <Jo...@163.com>
AuthorDate: Thu Jul 14 12:04:15 2022 +0800

    update
---
 README_CN.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README_CN.md b/README_CN.md
index 8b0a573..d2439c4 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -1,4 +1,4 @@
-bubbo-rust
+dubbo-rust
 =========
 
 Rust implementation of [gRPC] protocol for [Dubbo], under development.
@@ -8,7 +8,7 @@ Rust implementation of [gRPC] protocol for [Dubbo], under development.
 
 ## Overview
 
-[`bubbo-rust`] is composed of three main components: the generic gRPC implementation, the gRPC codegen 
+[`dubbo-rust`] is composed of three main components: the generic gRPC implementation, the gRPC codegen 
 implementation with dubbo-build powered by [`prost`]. The transporter layer implementation can support any HTTP/2
 implementation is based on [`hyper`], [`tower`]. The message layer implementation can support any user defined bytes format.
 


[dubbo-rust] 14/35: Fix: add new git ignore content.

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 291a41b970a84a8a410b031d199bc7b271c3ced1
Author: Zonglei Dong <do...@apache.org>
AuthorDate: Fri May 6 15:25:39 2022 +0800

    Fix: add new git ignore content.
---
 .gitignore | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/.gitignore b/.gitignore
index 4fffb2f..386dbf6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,5 @@
 /target
 /Cargo.lock
+**/*.rs.bk
+.vscode/
+.idea/


[dubbo-rust] 30/35: Update server.rs

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit d4d667ed129405d2b1ef60ae7d0d161bda21888f
Author: Johankoi <Jo...@163.com>
AuthorDate: Thu Jul 21 17:17:09 2022 +0800

    Update server.rs
    
    fix RpcServer start function
---
 xds/src/server/server.rs | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/xds/src/server/server.rs b/xds/src/server/server.rs
index f27bc0a..f45a37f 100644
--- a/xds/src/server/server.rs
+++ b/xds/src/server/server.rs
@@ -35,14 +35,7 @@ impl RpcServer {
         }
     }
 
-    pub async fn start<S>(&self, service: S)
-        where
-            S: Service<Request<Body>, Response = Response<Body>, Error = Infallible>
-            + Clone
-            + Send
-            + 'static,
-            S::Future: Send + 'static,
-    {
+    pub async fn start(&self) {
         env_logger::init();
 
         let make_service = make_service_fn(|_conn| async {


[dubbo-rust] 02/35: repo configuration

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 961471bf85cab25f4094d1c1b40e8f16d78c62c3
Author: ken.lj <ke...@gmail.com>
AuthorDate: Sun Apr 3 11:30:32 2022 +0800

    repo configuration
---
 .asf.yaml | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/.asf.yaml b/.asf.yaml
new file mode 100644
index 0000000..11f9b19
--- /dev/null
+++ b/.asf.yaml
@@ -0,0 +1,38 @@
+#
+#
+#   Licensed to the Apache Software Foundation (ASF) under one or more
+#   contributor license agreements.  See the NOTICE file distributed with
+#   this work for additional information regarding copyright ownership.
+#   The ASF licenses this file to You 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.
+#
+#
+
+notifications:
+  commits:      commits@dubbo.apache.org
+  issues:       notifications@dubbo.apache.org
+  pullrequests: notifications@dubbo.apache.org
+  jira_options: link label link label
+
+github:
+  homepage: https://dubbo.apache.org/
+  features:
+    # Enable wiki for documentation
+    wiki: true
+    # Enable issue management
+    issues: true
+    # Enable projects for project management boards
+    projects: true
+  protected_branches:
+    master:
+      # only disable force push
+      foo: bar


[dubbo-rust] 03/35: dubbo-rust begin with first commit

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 7b5687b2ae8181f931748b204911b02e183a26a2
Author: hanxiaoqing <ha...@rongcloud.cn>
AuthorDate: Sun Apr 24 18:33:52 2022 +0800

    dubbo-rust begin with first commit
    
    Signed-off-by: hanxiaoqing <ha...@rongcloud.cn>
---
 .gitignore                                 |   2 +
 Cargo.toml                                 |   9 ++
 LICENSE                                    | 191 +++++++++++++++++++++++++++++
 README_CN.md                               |   0
 common/Cargo.toml                          |   8 ++
 common/src/lib.rs                          |   8 ++
 config/Cargo.toml                          |   8 ++
 config/src/lib.rs                          |   8 ++
 contributing.md                            |  31 +++++
 examples/Cargo.toml                        |  40 ++++++
 examples/LICENSE                           |  19 +++
 examples/README.md                         |   0
 examples/build.rs                          |   0
 examples/example-tutorial.md               |   0
 examples/proto/helloworld/helloworld.proto |  37 ++++++
 examples/src/grpc-web/client.rs            |   0
 examples/src/grpc-web/server.rs            |   0
 examples/src/helloworld/client.rs          |   0
 examples/src/helloworld/server.rs          |   0
 examples/src/helloworld/server_blocking.rs |   0
 metadata/Cargo.toml                        |   8 ++
 metadata/src/lib.rs                        |   8 ++
 protocol/Cargo.toml                        |   8 ++
 protocol/src/lib.rs                        |   8 ++
 registry/Cargo.toml                        |   8 ++
 registry/src/lib.rs                        |   8 ++
 xds/Cargo.toml                             |   8 ++
 xds/src/client/client.rs                   |   0
 xds/src/client/mod.rs                      |   0
 xds/src/lib.rs                             |   8 ++
 xds/src/server/mod.rs                      |   0
 xds/src/server/server.rs                   |   0
 32 files changed, 425 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4fffb2f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/target
+/Cargo.lock
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..3720b7d
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,9 @@
+[workspace]
+members = [
+  "xds",
+  "protocol",
+  "registry",
+  "metadata",
+  "common",
+  "config",
+]
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d80bbda
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,191 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   Copyright (c) 2016 ~ 2018 Alex Stocks.
+
+   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.
diff --git a/README_CN.md b/README_CN.md
new file mode 100644
index 0000000..e69de29
diff --git a/common/Cargo.toml b/common/Cargo.toml
new file mode 100644
index 0000000..b7723d9
--- /dev/null
+++ b/common/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "common"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/common/src/lib.rs b/common/src/lib.rs
new file mode 100644
index 0000000..1b4a90c
--- /dev/null
+++ b/common/src/lib.rs
@@ -0,0 +1,8 @@
+#[cfg(test)]
+mod tests {
+    #[test]
+    fn it_works() {
+        let result = 2 + 2;
+        assert_eq!(result, 4);
+    }
+}
diff --git a/config/Cargo.toml b/config/Cargo.toml
new file mode 100644
index 0000000..b8afece
--- /dev/null
+++ b/config/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "config"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/config/src/lib.rs b/config/src/lib.rs
new file mode 100644
index 0000000..1b4a90c
--- /dev/null
+++ b/config/src/lib.rs
@@ -0,0 +1,8 @@
+#[cfg(test)]
+mod tests {
+    #[test]
+    fn it_works() {
+        let result = 2 + 2;
+        assert_eq!(result, 4);
+    }
+}
diff --git a/contributing.md b/contributing.md
new file mode 100644
index 0000000..b1265c2
--- /dev/null
+++ b/contributing.md
@@ -0,0 +1,31 @@
+Contributing to Dubbogo
+
+## 1. Branch
+
+  >- The name of branches `SHOULD` be in the format of `feature/xxx`.
+  >- You `SHOULD` checkout a new branch after a feature branch already being merged into upstream, `DO NOT` commit in the old branch.
+
+## 2. Pull Request
+
+### 2.1. Title Format
+
+The pr head format is `<head> <subject>`. The title should be simpler to show your intent.
+
+The title format of the pull request `MUST` follow the following rules:
+
+  >- Start with `Doc:` for adding/formatting/improving docs.
+  >- Start with `Mod:` for formatting codes or adding comment.
+  >- Start with `Fix:` for fixing bug, and its ending should be ` #issue-id` if being relevant to some issue.
+  >- Start with `Imp:` for improving performance.
+  >- Start with `Ftr:` for adding a new feature.
+  >- Start with `Add:` for adding struct function/member.
+  >- Start with `Rft:` for refactoring codes.
+  >- Start with `Tst:` for adding tests.
+  >- Start with `Dep:` for adding depending libs.
+  >- Start with `Rem:` for removing feature/struct/function/member/files.
+
+## 3. Code Style
+
+### 3.1 log
+
+> 1 when logging the function's input parameter, you should add '@' before input parameter name.
diff --git a/examples/Cargo.toml b/examples/Cargo.toml
new file mode 100644
index 0000000..3287f9c
--- /dev/null
+++ b/examples/Cargo.toml
@@ -0,0 +1,40 @@
+[package]
+authors = ["Johankio Smith <jo...@1991.com>"]
+edition = "2018"
+license = "MIT"
+name = "examples"
+publish = false
+version = "0.1.0"
+
+[[bin]]
+name = "helloworld-server"
+path = "src/helloworld/server.rs"
+
+[[bin]]
+name = "helloworld-client"
+path = "src/helloworld/client.rs"
+
+[[bin]]
+name = "grpc-web-server"
+path = "src/grpc-web/server.rs"
+
+[[bin]]
+name = "grpc-web-client"
+path = "src/grpc-web/client.rs"
+
+[dependencies]
+async-stream = "0.3"
+futures = { version = "0.3", default-features = false, features = ["alloc"] }
+prost = "0.10"
+tokio = { version = "1.0", features = [ "rt-multi-thread", "time", "fs", "macros", "net",] }
+tokio-stream = { version = "0.1", features = ["net"] }
+# Required for wellknown types
+prost-types = "0.10"
+# grpc-web example
+bytes = "1"
+tokio-rustls = "*"
+hyper-rustls = { version = "0.23", features = ["http2"] }
+rustls-pemfile = "*"
+tower-http = { version = "0.2", features = ["add-extension"] }
+
+[build-dependencies]
diff --git a/examples/LICENSE b/examples/LICENSE
new file mode 100644
index 0000000..3077098
--- /dev/null
+++ b/examples/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2020 Lucio Franco
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/examples/README.md b/examples/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/examples/build.rs b/examples/build.rs
new file mode 100644
index 0000000..e69de29
diff --git a/examples/example-tutorial.md b/examples/example-tutorial.md
new file mode 100644
index 0000000..e69de29
diff --git a/examples/proto/helloworld/helloworld.proto b/examples/proto/helloworld/helloworld.proto
new file mode 100644
index 0000000..8de5d08
--- /dev/null
+++ b/examples/proto/helloworld/helloworld.proto
@@ -0,0 +1,37 @@
+// Copyright 2015 gRPC authors.
+//
+// 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.
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "io.grpc.examples.helloworld";
+option java_outer_classname = "HelloWorldProto";
+
+package helloworld;
+
+// The greeting service definition.
+service Greeter {
+  // Sends a greeting
+  rpc SayHello (HelloRequest) returns (HelloReply) {}
+}
+
+// The request message containing the user's name.
+message HelloRequest {
+  string name = 1;
+}
+
+// The response message containing the greetings
+message HelloReply {
+  string message = 1;
+}
\ No newline at end of file
diff --git a/examples/src/grpc-web/client.rs b/examples/src/grpc-web/client.rs
new file mode 100644
index 0000000..e69de29
diff --git a/examples/src/grpc-web/server.rs b/examples/src/grpc-web/server.rs
new file mode 100644
index 0000000..e69de29
diff --git a/examples/src/helloworld/client.rs b/examples/src/helloworld/client.rs
new file mode 100644
index 0000000..e69de29
diff --git a/examples/src/helloworld/server.rs b/examples/src/helloworld/server.rs
new file mode 100644
index 0000000..e69de29
diff --git a/examples/src/helloworld/server_blocking.rs b/examples/src/helloworld/server_blocking.rs
new file mode 100644
index 0000000..e69de29
diff --git a/metadata/Cargo.toml b/metadata/Cargo.toml
new file mode 100644
index 0000000..a600f4c
--- /dev/null
+++ b/metadata/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "metadata"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/metadata/src/lib.rs b/metadata/src/lib.rs
new file mode 100644
index 0000000..1b4a90c
--- /dev/null
+++ b/metadata/src/lib.rs
@@ -0,0 +1,8 @@
+#[cfg(test)]
+mod tests {
+    #[test]
+    fn it_works() {
+        let result = 2 + 2;
+        assert_eq!(result, 4);
+    }
+}
diff --git a/protocol/Cargo.toml b/protocol/Cargo.toml
new file mode 100644
index 0000000..77c8260
--- /dev/null
+++ b/protocol/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "protocol"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/protocol/src/lib.rs b/protocol/src/lib.rs
new file mode 100644
index 0000000..1b4a90c
--- /dev/null
+++ b/protocol/src/lib.rs
@@ -0,0 +1,8 @@
+#[cfg(test)]
+mod tests {
+    #[test]
+    fn it_works() {
+        let result = 2 + 2;
+        assert_eq!(result, 4);
+    }
+}
diff --git a/registry/Cargo.toml b/registry/Cargo.toml
new file mode 100644
index 0000000..89c58fc
--- /dev/null
+++ b/registry/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "registry"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/registry/src/lib.rs b/registry/src/lib.rs
new file mode 100644
index 0000000..1b4a90c
--- /dev/null
+++ b/registry/src/lib.rs
@@ -0,0 +1,8 @@
+#[cfg(test)]
+mod tests {
+    #[test]
+    fn it_works() {
+        let result = 2 + 2;
+        assert_eq!(result, 4);
+    }
+}
diff --git a/xds/Cargo.toml b/xds/Cargo.toml
new file mode 100644
index 0000000..75e2515
--- /dev/null
+++ b/xds/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "xds"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/xds/src/client/client.rs b/xds/src/client/client.rs
new file mode 100644
index 0000000..e69de29
diff --git a/xds/src/client/mod.rs b/xds/src/client/mod.rs
new file mode 100644
index 0000000..e69de29
diff --git a/xds/src/lib.rs b/xds/src/lib.rs
new file mode 100644
index 0000000..1b4a90c
--- /dev/null
+++ b/xds/src/lib.rs
@@ -0,0 +1,8 @@
+#[cfg(test)]
+mod tests {
+    #[test]
+    fn it_works() {
+        let result = 2 + 2;
+        assert_eq!(result, 4);
+    }
+}
diff --git a/xds/src/server/mod.rs b/xds/src/server/mod.rs
new file mode 100644
index 0000000..e69de29
diff --git a/xds/src/server/server.rs b/xds/src/server/server.rs
new file mode 100644
index 0000000..e69de29


[dubbo-rust] 19/35: Fix: add license header for file.

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit fbd62f376de39f1744b1ad9473c5026eaef8b99e
Author: Zonglei Dong <do...@apache.org>
AuthorDate: Sat May 14 15:39:53 2022 +0800

    Fix: add license header for file.
---
 common/src/lib.rs        | 17 +++++++++++++++++
 config/src/lib.rs        | 17 +++++++++++++++++
 metadata/src/lib.rs      | 17 +++++++++++++++++
 protocol/src/lib.rs      | 17 +++++++++++++++++
 registry/src/lib.rs      | 17 +++++++++++++++++
 xds/src/client/client.rs | 16 ++++++++++++++++
 xds/src/client/mod.rs    | 16 ++++++++++++++++
 xds/src/lib.rs           | 17 +++++++++++++++++
 xds/src/server/mod.rs    | 16 ++++++++++++++++
 xds/src/server/server.rs | 16 ++++++++++++++++
 10 files changed, 166 insertions(+)

diff --git a/common/src/lib.rs b/common/src/lib.rs
index 1b4a90c..3e01853 100644
--- a/common/src/lib.rs
+++ b/common/src/lib.rs
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
 #[cfg(test)]
 mod tests {
     #[test]
diff --git a/config/src/lib.rs b/config/src/lib.rs
index 1b4a90c..3e01853 100644
--- a/config/src/lib.rs
+++ b/config/src/lib.rs
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
 #[cfg(test)]
 mod tests {
     #[test]
diff --git a/metadata/src/lib.rs b/metadata/src/lib.rs
index 1b4a90c..3e01853 100644
--- a/metadata/src/lib.rs
+++ b/metadata/src/lib.rs
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
 #[cfg(test)]
 mod tests {
     #[test]
diff --git a/protocol/src/lib.rs b/protocol/src/lib.rs
index 1b4a90c..3e01853 100644
--- a/protocol/src/lib.rs
+++ b/protocol/src/lib.rs
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
 #[cfg(test)]
 mod tests {
     #[test]
diff --git a/registry/src/lib.rs b/registry/src/lib.rs
index 1b4a90c..3e01853 100644
--- a/registry/src/lib.rs
+++ b/registry/src/lib.rs
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
 #[cfg(test)]
 mod tests {
     #[test]
diff --git a/xds/src/client/client.rs b/xds/src/client/client.rs
index e69de29..2944f98 100644
--- a/xds/src/client/client.rs
+++ b/xds/src/client/client.rs
@@ -0,0 +1,16 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
diff --git a/xds/src/client/mod.rs b/xds/src/client/mod.rs
index e69de29..2944f98 100644
--- a/xds/src/client/mod.rs
+++ b/xds/src/client/mod.rs
@@ -0,0 +1,16 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
diff --git a/xds/src/lib.rs b/xds/src/lib.rs
index 1b4a90c..3e01853 100644
--- a/xds/src/lib.rs
+++ b/xds/src/lib.rs
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
 #[cfg(test)]
 mod tests {
     #[test]
diff --git a/xds/src/server/mod.rs b/xds/src/server/mod.rs
index e69de29..2944f98 100644
--- a/xds/src/server/mod.rs
+++ b/xds/src/server/mod.rs
@@ -0,0 +1,16 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
diff --git a/xds/src/server/server.rs b/xds/src/server/server.rs
index e69de29..2944f98 100644
--- a/xds/src/server/server.rs
+++ b/xds/src/server/server.rs
@@ -0,0 +1,16 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */


[dubbo-rust] 13/35: Fix: fix spelling mistake.

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit c0a6af926b0ecce61bddc6d0ec9e416f37d4def9
Author: Zonglei Dong <do...@apache.org>
AuthorDate: Fri May 6 15:18:37 2022 +0800

    Fix: fix spelling mistake.
---
 .github/workflows/CI.yml | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index b377439..f78275a 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -12,7 +12,7 @@ on:
 
 jobs:
  check:
-    name: check dubbo-rus project
+    name: check dubbo-rust project
     runs-on: ${{ matrix.os }}
     strategy:
       matrix:
@@ -44,11 +44,3 @@ jobs:
           toolchain: ${{ matrix.rust }}
       - run: rustup component add rustfmt
       - run: cargo fmt --all -- --check
-      
-  
-
-    
-
-
-   
-   


[dubbo-rust] 29/35: finished 1.0.0

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 60bfedf3134569b97dd7648cc747ebb05476250c
Author: hxq <jo...@163.com>
AuthorDate: Thu Jul 21 16:25:11 2022 +0800

    finished 1.0.0
---
 .github/.DS_Store                      | Bin 0 -> 6148 bytes
 dubbo-build/.DS_Store                  | Bin 0 -> 6148 bytes
 dubbo-build/src/generator.rs           | 106 +++++++++++++++++-------
 dubbo-build/src/lib.rs                 |  17 +++-
 examples/.DS_Store                     | Bin 0 -> 6148 bytes
 examples/grpc-gen/.DS_Store            | Bin 0 -> 6148 bytes
 examples/grpc-gen/Cargo.toml           |  14 +++-
 examples/grpc-gen/build.rs             |   3 +-
 examples/grpc-gen/src/.DS_Store        | Bin 0 -> 6148 bytes
 examples/grpc-gen/src/client.rs        |  10 +++
 examples/grpc-gen/src/greeter.rs       |  68 +++++++++++-----
 examples/grpc-gen/src/lib.rs           |   6 ++
 examples/grpc-gen/src/main.rs          |  12 ---
 examples/grpc-gen/src/server.rs        |  38 +++++++++
 examples/protobuf-transport/src/lib.rs |   2 +-
 xds/.DS_Store                          | Bin 0 -> 6148 bytes
 xds/src/.DS_Store                      | Bin 0 -> 6148 bytes
 xds/src/client/client.rs               |  34 +++++++-
 xds/src/error.rs                       |  17 ++++
 xds/src/lib.rs                         |   3 -
 xds/src/protocol/error.rs              |  17 ++++
 xds/src/protocol/message.rs            |  17 ++++
 xds/src/protocol/mod.rs                |  17 ++++
 xds/src/request.rs                     | 143 ++++++++++++++++-----------------
 xds/src/response.rs                    | 116 +++++++++++++-------------
 xds/src/server/.DS_Store               | Bin 0 -> 6148 bytes
 xds/src/server/server.rs               |  17 ++--
 xds/src/util.rs                        |  17 ++++
 xds/src/wrapper.rs                     | 110 -------------------------
 29 files changed, 467 insertions(+), 317 deletions(-)

diff --git a/.github/.DS_Store b/.github/.DS_Store
new file mode 100644
index 0000000..3bb81dc
Binary files /dev/null and b/.github/.DS_Store differ
diff --git a/dubbo-build/.DS_Store b/dubbo-build/.DS_Store
new file mode 100644
index 0000000..cd16f51
Binary files /dev/null and b/dubbo-build/.DS_Store differ
diff --git a/dubbo-build/src/generator.rs b/dubbo-build/src/generator.rs
index 05e25cf..79fa172 100644
--- a/dubbo-build/src/generator.rs
+++ b/dubbo-build/src/generator.rs
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
 use prost_build::{Method, Service, ServiceGenerator};
 
 #[derive(Default)]
@@ -8,17 +25,32 @@ impl CodeGenerator {
 
     fn generate_module_name(&self) -> &str { "xds" }
 
-    fn generate_type_aliases(&mut self, buf: &mut String) {
+    fn generate_uses(&mut self, buf: &mut String) {
         buf.push_str(&format!(
             "\n\
-                pub type DBReq<I> = {0}::request::ServiceRequest<I>;\n\
-                pub type DBResp<O> = Result<{0}::response::ServiceResponse<O>, {0}::error::DBProstError>;\n",
+                use async_trait::async_trait;\n\
+                use tower::Service;\n\
+                use hyper::{{\n    \
+                    Body,\n    \
+                    Request,\n    \
+                    Response,\n\
+                }};\n\
+                use futures::future::{{\n    \
+                    BoxFuture\n\
+                }};\n\
+                use std::{{\n    \
+                    task::{{Poll}},\n\
+                }};\n"));
+    }
+
+    fn generate_type_aliases(&mut self, buf: &mut String) {
+        buf.push_str(&format!(
+            "\npub type DBResp<O> = Result<{0}::response::ServiceResponse<O>, {0}::error::DBProstError>;\n",
             self.generate_module_name()));
     }
 
     fn generate_main_trait(&self, service: &Service, buf: &mut String) {
-        buf.push_str("\nuse async_trait::async_trait;\n\n#[async_trait]\n");
-
+        buf.push_str("\n\n#[async_trait]\n");
         service.comments.append_with_indent(0, buf);
         buf.push_str(&format!("pub trait {} {{", service.name));
         for method in service.methods.iter() {
@@ -30,7 +62,7 @@ impl CodeGenerator {
     }
 
     fn method_sig(&self, method: &Method) -> String {
-        format!("async fn {0}(&self, request: DBReq<{1}>) -> DBResp<{2}>",
+        format!("async fn {0}(&self, request: {1}) -> DBResp<{2}>",
                 method.name, method.input_type, method.output_type)
     }
 
@@ -38,7 +70,7 @@ impl CodeGenerator {
         buf.push_str(&format!(
             "\n\
             pub struct {0}Client {{\n    \
-                pub hyper_client: {1}::wrapper::HyperClient \n\
+                pub rpc_client: {1}::client::RpcClient \n\
             }}\n",service.name, self.generate_module_name()));
     }
 
@@ -46,9 +78,9 @@ impl CodeGenerator {
         buf.push_str(&format!(
             "\n\
             impl {0}Client {{\n     \
-               pub fn new(root_url: &str) -> {0}Client {{\n        \
+               pub fn new(addr: String) -> {0}Client {{\n        \
                    {0}Client {{\n            \
-                        hyper_client: {1}::wrapper::HyperClient::new(root_url) \n        \
+                        rpc_client: {1}::client::RpcClient::new(addr) \n        \
                    }}\n     \
                }}\n\
             }}\n", service.name, self.generate_module_name()));
@@ -58,8 +90,9 @@ impl CodeGenerator {
 
         for method in service.methods.iter() {
             buf.push_str(&format!(
-                "\n    {} {{\n        \
-                    self.hyper_client.request(\"/dubbo/{}.{}/{}\", request).await\n    \
+                "\n    {0} {{\n        \
+                    let path = \"dubbo/{1}.{2}/{3}\".to_owned();\n        \
+                    self.rpc_client.request(request, path).await\n    \
                 }}\n", self.method_sig(method), service.package, service.proto_name, method.proto_name));
         }
         buf.push_str("}\n");
@@ -69,50 +102,64 @@ impl CodeGenerator {
         buf.push_str(&format!(
             "\n\
             pub struct {0}Server<T: 'static + {0} + Send + Sync + Clone> {{\n    \
-                pub hyper_server: {1}::wrapper::HyperServer<T> \n\
-            }}\n",service.name, self.generate_module_name()));
+                pub inner: T\n\
+            }}\n",service.name));
     }
 
     fn generate_server_impl(&self, service: &Service, buf: &mut String) {
         buf.push_str(&format!(
             "\n\
              impl<T: 'static + {0} + Send + Sync + Clone> {0}Server<T> {{\n    \
-                pub fn new(&self, service: T) -> {0}Server<T> {{\n        \
+                pub fn new(service: T) -> {0}Server<T> {{\n        \
                     {0}Server {{\n            \
-                        hyper_server: {1}::wrapper::HyperServer::new(service) \n        \
+                        inner: service \n        \
                    }}\n     \
                 }}\n\
             }}\n",
-            service.name, self.generate_module_name()));
+            service.name));
 
         buf.push_str(&format!(
             "\n\
-            impl<T: 'static + {0} + Send + Sync + Clone> {1}::wrapper::HyperService for {0}Server<T> {{\n    \
-                fn handle(&self, req: DBReq<Vec<u8>>) -> {1}::BoxFutureResp<Vec<u8>> {{\n       \
-                    use ::futures::Future;\n       \
-                    let trait_object_service = self.hyper_server.service.clone();\n       \
-                    match (req.method.clone(), req.uri.path()) {{",
-            service.name, self.generate_module_name()));
+            impl<T> Service<Request<Body>> for {0}Server<T> \n    \
+                where T: 'static + Greeter + Send + Sync + Clone {{\n    \
+                type Response = Response<Body>;\n    \
+                type Error = hyper::Error;\n    \
+                type Future = BoxFuture<'static, Result<Self::Response, Self::Error>>;\n    \
+                \n    \
+
+                fn poll_ready(&mut self, _cx: &mut std::task::Context<'_>) -> Poll<Result<(), Self::Error>> {{\n        \
+                    Poll::Ready(Ok(()))\n    \
+                }}\n    \
+
+                \n    \
+
+                fn call(&mut self, req: Request<Body>) -> Self::Future {{\n       \
+                    let inner = self.inner.clone();\n       \
+                    let url = req.uri().path();\n       \
+                    match (req.method().clone(), url) {{",
+            service.name));
 
         // Make match arms for each type
         for method in service.methods.iter() {
             buf.push_str(&format!(
                 "\n          \
                 (::hyper::Method::POST, \"/dubbo/{0}.{1}/{2}\") => {{\n              \
-                    Box::pin(async move {{ \n                  \
-                        let proto_req = req.to_proto().unwrap();  \n                  \
-                        let resp = trait_object_service.{3}(proto_req).await.unwrap();  \n                  \
-                        let proto_resp = resp.to_proto_raw();  \n                  \
-                        proto_resp  \n               \
+                    Box::pin(async move {{\n                  \
+                        let request = {3}::ServiceRequest::try_from_hyper(req).await;\n                  \
+                        let proto_req = request.unwrap().try_decode().unwrap();\n                  \
+                        let resp = inner.{4}(proto_req.input).await.unwrap();\n                  \
+                        let proto_resp = resp.try_encode();\n                  \
+                        let hyper_resp = proto_resp.unwrap().into_hyper();\n                  \
+                        Ok(hyper_resp)  \n               \
                     }}) \n           \
-                 }},", service.package, service.proto_name, method.proto_name, method.name));
+                 }},", service.package, service.proto_name, method.proto_name, self.generate_module_name(), method.name));
         }
         // Final 404 arm and end fn
         buf.push_str(&format!(
             "\n          \
                 _ => {{\n            \
                     Box::pin(async move {{ \n                \
-                        Ok({0}::error::DBError::new(::hyper::StatusCode::NOT_FOUND, \"not_found\", \"Not found\").to_resp_raw()) \n            \
+                        Ok({0}::error::DBError::new(::hyper::StatusCode::NOT_FOUND, \"not_found\", \"Not found\").to_hyper_resp()) \n            \
                     }}) \n          \
                 }}\n       \
             }}\n   \
@@ -123,6 +170,7 @@ impl CodeGenerator {
 
 impl ServiceGenerator for CodeGenerator {
     fn generate(&mut self, service: Service, buf: &mut String) {
+        self.generate_uses(buf);
         self.generate_type_aliases(buf);
         self.generate_main_trait(&service, buf);
         self.generate_client_struct(&service, buf);
diff --git a/dubbo-build/src/lib.rs b/dubbo-build/src/lib.rs
index 329eb39..225d4f6 100644
--- a/dubbo-build/src/lib.rs
+++ b/dubbo-build/src/lib.rs
@@ -1,4 +1,19 @@
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
 
 #[cfg(feature = "generator-code")]
 extern crate prost_build;
diff --git a/examples/.DS_Store b/examples/.DS_Store
new file mode 100644
index 0000000..0d3b142
Binary files /dev/null and b/examples/.DS_Store differ
diff --git a/examples/grpc-gen/.DS_Store b/examples/grpc-gen/.DS_Store
new file mode 100644
index 0000000..b57983e
Binary files /dev/null and b/examples/grpc-gen/.DS_Store differ
diff --git a/examples/grpc-gen/Cargo.toml b/examples/grpc-gen/Cargo.toml
index 335c81c..7122d68 100644
--- a/examples/grpc-gen/Cargo.toml
+++ b/examples/grpc-gen/Cargo.toml
@@ -6,13 +6,25 @@ edition = "2021"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
+tokio = {version = "1.9.0", features = ["full"]}
 futures = "0.3.21"
 prost = "0.10.4"
 async-trait = { version = "0.1.56" }
 xds = { version = "0.1.0", path = "../../xds" }
-
 hyper = { version = "0.14.19", features = ["full"] }
+pin-project = "1.0.11"
+tower = "0.4"
+
+[lib]
+path = "./src/lib.rs"
+
+[[bin]]
+name="server"
+path="./src/server.rs"
 
+[[bin]]
+name="client"
+path="./src/client.rs"
 
 
 [build-dependencies]
diff --git a/examples/grpc-gen/build.rs b/examples/grpc-gen/build.rs
index 0098c18..7a3e44f 100644
--- a/examples/grpc-gen/build.rs
+++ b/examples/grpc-gen/build.rs
@@ -3,10 +3,9 @@ use prost_build::Config;
 
 fn main() -> Result<()> {
     let mut conf = Config::new();
-    let mut gen = dubbo_build::CodeGenerator::new();
+    let gen = dubbo_build::CodeGenerator::new();
     conf.service_generator(Box::new(gen));
     conf.out_dir("src/");
     conf.compile_protos(&["pb/greeter.proto"], &["pb/"]).unwrap();
-
     Ok(())
 }
\ No newline at end of file
diff --git a/examples/grpc-gen/src/.DS_Store b/examples/grpc-gen/src/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/examples/grpc-gen/src/.DS_Store differ
diff --git a/examples/grpc-gen/src/client.rs b/examples/grpc-gen/src/client.rs
new file mode 100644
index 0000000..0f846a8
--- /dev/null
+++ b/examples/grpc-gen/src/client.rs
@@ -0,0 +1,10 @@
+
+mod greeter;
+use greeter::*;
+#[tokio::main]
+async fn main() {
+    let client =  GreeterClient::new("http://127.0.0.1:8972".to_owned());
+    let resp = client.say_hello(HelloRequest { name: "johankoi".into()}).await.unwrap();
+    let hello_resp = resp.output;
+    println!("{}",hello_resp.message);
+}
\ No newline at end of file
diff --git a/examples/grpc-gen/src/greeter.rs b/examples/grpc-gen/src/greeter.rs
index 3ecb8f2..9895a76 100644
--- a/examples/grpc-gen/src/greeter.rs
+++ b/examples/grpc-gen/src/greeter.rs
@@ -9,63 +9,87 @@ pub struct HelloResponse {
     pub message: ::prost::alloc::string::String,
 }
 
-pub type DBReq<I> = xds::request::ServiceRequest<I>;
+use async_trait::async_trait;
+use tower::Service;
+use hyper::{
+    Body,
+    Request,
+    Response,
+};
+use futures::future::{
+    BoxFuture
+};
+use std::{
+    task::{Poll},
+};
+
 pub type DBResp<O> = Result<xds::response::ServiceResponse<O>, xds::error::DBProstError>;
 
-use async_trait::async_trait;
 
 #[async_trait]
 pub trait Greeter {
-   async fn say_hello(&self, request: DBReq<HelloRequest>) -> DBResp<HelloResponse>;
+   async fn say_hello(&self, request: HelloRequest) -> DBResp<HelloResponse>;
 }
 
 pub struct GreeterClient {
-    pub hyper_client: xds::wrapper::HyperClient 
+    pub rpc_client: xds::client::RpcClient 
 }
 
 impl GreeterClient {
-     pub fn new(root_url: &str) -> GreeterClient {
+     pub fn new(addr: String) -> GreeterClient {
         GreeterClient {
-            hyper_client: xds::wrapper::HyperClient::new(root_url) 
+            rpc_client: xds::client::RpcClient::new(addr) 
         }
      }
 }
 
 #[async_trait]
 impl Greeter for GreeterClient {
-    async fn say_hello(&self, request: DBReq<HelloRequest>) -> DBResp<HelloResponse> {
-        self.hyper_client.request("/dubbo/greeter.Greeter/SayHello", request).await
+    async fn say_hello(&self, request: HelloRequest) -> DBResp<HelloResponse> {
+        let path = "dubbo/greeter.Greeter/SayHello".to_owned();
+        self.rpc_client.request(request, path).await
     }
 }
 
 pub struct GreeterServer<T: 'static + Greeter + Send + Sync + Clone> {
-    pub hyper_server: xds::wrapper::HyperServer<T> 
+    pub inner: T
 }
 
 impl<T: 'static + Greeter + Send + Sync + Clone> GreeterServer<T> {
-    pub fn new(&self, service: T) -> GreeterServer<T> {
+    pub fn new(service: T) -> GreeterServer<T> {
         GreeterServer {
-            hyper_server: xds::wrapper::HyperServer::new(service) 
+            inner: service 
         }
      }
 }
 
-impl<T: 'static + Greeter + Send + Sync + Clone> xds::wrapper::HyperService for GreeterServer<T> {
-    fn handle(&self, req: DBReq<Vec<u8>>) -> xds::BoxFutureResp<Vec<u8>> {
-       use ::futures::Future;
-       let trait_object_service = self.hyper_server.service.clone();
-       match (req.method.clone(), req.uri.path()) {
+impl<T> Service<Request<Body>> for GreeterServer<T> 
+    where T: 'static + Greeter + Send + Sync + Clone {
+    type Response = Response<Body>;
+    type Error = hyper::Error;
+    type Future = BoxFuture<'static, Result<Self::Response, Self::Error>>;
+    
+    fn poll_ready(&mut self, _cx: &mut std::task::Context<'_>) -> Poll<Result<(), Self::Error>> {
+        Poll::Ready(Ok(()))
+    }
+    
+    fn call(&mut self, req: Request<Body>) -> Self::Future {
+       let inner = self.inner.clone();
+       let url = req.uri().path();
+       match (req.method().clone(), url) {
           (::hyper::Method::POST, "/dubbo/greeter.Greeter/SayHello") => {
-              Box::pin(async move { 
-                  let proto_req = req.to_proto().unwrap();  
-                  let resp = trait_object_service.say_hello(proto_req).await.unwrap();  
-                  let proto_resp = resp.to_proto_raw();  
-                  proto_resp  
+              Box::pin(async move {
+                  let request = xds::ServiceRequest::try_from_hyper(req).await;
+                  let proto_req = request.unwrap().try_decode().unwrap();
+                  let resp = inner.say_hello(proto_req.input).await.unwrap();
+                  let proto_resp = resp.try_encode();
+                  let hyper_resp = proto_resp.unwrap().into_hyper();
+                  Ok(hyper_resp)  
                }) 
            },
           _ => {
             Box::pin(async move { 
-                Ok(xds::error::DBError::new(::hyper::StatusCode::NOT_FOUND, "not_found", "Not found").to_resp_raw()) 
+                Ok(xds::error::DBError::new(::hyper::StatusCode::NOT_FOUND, "not_found", "Not found").to_hyper_resp()) 
             }) 
           }
        }
diff --git a/examples/grpc-gen/src/lib.rs b/examples/grpc-gen/src/lib.rs
new file mode 100644
index 0000000..c032559
--- /dev/null
+++ b/examples/grpc-gen/src/lib.rs
@@ -0,0 +1,6 @@
+
+
+fn main() {
+
+
+}
diff --git a/examples/grpc-gen/src/main.rs b/examples/grpc-gen/src/main.rs
deleted file mode 100644
index 68b341a..0000000
--- a/examples/grpc-gen/src/main.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-
-mod greeter;
-use greeter::*;
-
-
-fn main() {
-
-    let client =  GreeterClient::new("0.0.0.0:8080");
-    let hello_req = DBReq::new(HelloRequest { name: "johankoi".into()});
-    client.say_hello(hello_req);
-
-}
diff --git a/examples/grpc-gen/src/server.rs b/examples/grpc-gen/src/server.rs
new file mode 100644
index 0000000..3c15554
--- /dev/null
+++ b/examples/grpc-gen/src/server.rs
@@ -0,0 +1,38 @@
+use std::convert::Infallible;
+use std::net::SocketAddr;
+use async_trait::async_trait;
+use hyper::{Server as hyper_server};
+use hyper::service::{make_service_fn};
+
+mod greeter;
+use greeter::*;
+use xds::ServiceResponse;
+
+
+#[derive(Default, Clone)]
+pub struct HelloService {}
+
+#[async_trait]
+impl Greeter for HelloService {
+    async fn say_hello(&self, request: HelloRequest) -> DBResp<HelloResponse> {
+        println!("{}",request.name);
+        Ok(ServiceResponse::new(HelloResponse { message: "hello, dubbo rust!".into() }))
+    }
+}
+
+
+#[tokio::main]
+async fn main() {
+    let addr = SocketAddr::from(([127, 0, 0, 1], 8972));
+    let make_service = make_service_fn(|_conn| async {
+        let server = GreeterServer::new(HelloService::default());
+        Ok::<_, Infallible>(server)
+    });
+
+    let server = hyper_server::bind(&addr).serve(make_service);
+    println!("Listening on http://{}", &addr);
+    if let Err(e) = server.await {
+        eprintln!("server error: {}", e);
+    }
+}
+
diff --git a/examples/protobuf-transport/src/lib.rs b/examples/protobuf-transport/src/lib.rs
index 959e687..5e94390 100644
--- a/examples/protobuf-transport/src/lib.rs
+++ b/examples/protobuf-transport/src/lib.rs
@@ -3,5 +3,5 @@ pub mod person;
 pub use person::*;
 
 fn main() {
-    println!("Hello, world!");
+
 }
diff --git a/xds/.DS_Store b/xds/.DS_Store
new file mode 100644
index 0000000..b8d457d
Binary files /dev/null and b/xds/.DS_Store differ
diff --git a/xds/src/.DS_Store b/xds/src/.DS_Store
new file mode 100644
index 0000000..05fc01e
Binary files /dev/null and b/xds/src/.DS_Store differ
diff --git a/xds/src/client/client.rs b/xds/src/client/client.rs
index 1387e36..3c0b655 100644
--- a/xds/src/client/client.rs
+++ b/xds/src/client/client.rs
@@ -21,8 +21,21 @@ use hyper::client::service::Connect;
 use hyper::service::Service;
 use hyper::{Body, Request, Response};
 
-use crate::protocol::message::*;
+use crate::protocol::message::{
+    Message as DubboMessage,
+    RpcxMessage,
+    Metadata,
+    MessageType,
+    CompressType,
+    SerializeType
+};
+
 use std::collections::HashMap;
+use prost::{Message};
+
+use crate::request::ServiceRequest;
+use crate::response::ServiceResponse;
+use crate::error::*;
 
 
 pub struct RpcClient {
@@ -36,6 +49,23 @@ impl RpcClient {
         }
     }
 
+    /// Invoke the given request for the given path and return a result of Result<ServiceResponse<O>, DBProstError>
+    pub async fn request<I, O>(&self, message: I, path: String) -> Result<ServiceResponse<O>, DBProstError>
+        where I: Message + Default + 'static,
+              O: Message + Default + 'static {
+
+        let url_str = format!("{}/{}", self.addr.as_str(), path.as_str());
+        let uri = url_str.parse::<hyper::Uri>().unwrap();
+
+        let req = ServiceRequest::new(message, uri.clone());
+        let hyper_req = req.into_encoded_hyper().unwrap();
+
+        let mut connect = Connect::new(HttpConnector::new(), Builder::new());
+        let mut send = connect.call(uri.clone()).await.map_err(DBProstError::HyperError).unwrap();
+        let hyper_resp = send.call(hyper_req).await.map_err(DBProstError::HyperError).unwrap();
+        ServiceResponse::decode_response(hyper_resp).await
+    }
+
     pub async fn call(
         &mut self,
         service_path: String,
@@ -44,7 +74,7 @@ impl RpcClient {
         payload: Vec<u8>
     ) -> std::result::Result<Response<Body>, Box<dyn std::error::Error + Send + Sync>>
     {
-        let mut req = Message::new();
+        let mut req = DubboMessage::new();
         req.set_version(0);
         req.set_message_type(MessageType::Request);
         req.set_serialize_type(SerializeType::Protobuf);
diff --git a/xds/src/error.rs b/xds/src/error.rs
index e212835..2748a2e 100644
--- a/xds/src/error.rs
+++ b/xds/src/error.rs
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
 use serde_json;
 use prost::{DecodeError, EncodeError};
 use hyper::{Body, Response, Method, Version, header, StatusCode};
diff --git a/xds/src/lib.rs b/xds/src/lib.rs
index d3a7e94..ba2a6b5 100644
--- a/xds/src/lib.rs
+++ b/xds/src/lib.rs
@@ -22,13 +22,10 @@ pub mod protocol;
 
 pub mod request;
 pub mod response;
-pub mod wrapper;
 pub mod error;
 pub mod util;
 
 
-
-pub use wrapper::*;
 pub use request::*;
 pub use response::*;
 pub use error::*;
diff --git a/xds/src/protocol/error.rs b/xds/src/protocol/error.rs
index c1cdd8f..1496243 100644
--- a/xds/src/protocol/error.rs
+++ b/xds/src/protocol/error.rs
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
 use std::{convert::From, error, fmt, result, str};
 
 pub type Result<T> = result::Result<T, Error>;
diff --git a/xds/src/protocol/message.rs b/xds/src/protocol/message.rs
index 1895172..52bb806 100644
--- a/xds/src/protocol/message.rs
+++ b/xds/src/protocol/message.rs
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
 use byteorder::{BigEndian, ByteOrder};
 use enum_primitive_derive::Primitive;
 use flate2::{read::GzDecoder, write::GzEncoder, Compression};
diff --git a/xds/src/protocol/mod.rs b/xds/src/protocol/mod.rs
index 1d650a8..b9eaa8f 100644
--- a/xds/src/protocol/mod.rs
+++ b/xds/src/protocol/mod.rs
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
 pub mod error;
 pub mod message;
 
diff --git a/xds/src/request.rs b/xds/src/request.rs
index 4d497c0..c27aa91 100644
--- a/xds/src/request.rs
+++ b/xds/src/request.rs
@@ -1,6 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+use std::convert::From;
 use hyper::{body, Body, Request, Uri, Method, Version, header};
 use prost::{Message};
-use crate::util::*;
 use crate::error::*;
 
 /// A request with HTTP info and the serialized input object
@@ -22,15 +39,14 @@ pub struct ServiceRequest<T> {
     pub input: T,
 }
 
-impl<T> ServiceRequest<T> {
+impl<T: Message + Default + 'static> ServiceRequest<T> {
     /// Create new service request with the given input object
-    ///
     /// This automatically sets the `Content-Type` header as `application/protobuf`.
-    pub fn new(input: T) -> ServiceRequest<T> {
+    pub fn new(input: T, uri: Uri) -> ServiceRequest<T> {
         let mut header = header::HeaderMap::new();
         header.insert(header::CONTENT_TYPE, "application/protobuf".parse().unwrap());
         ServiceRequest {
-            uri: Default::default(),
+            uri,
             method: Method::POST,
             version: Version::default(),
             headers: header,
@@ -38,41 +54,41 @@ impl<T> ServiceRequest<T> {
         }
     }
 
-    /// Copy this request with a different input value
-    pub fn clone_with_input<U>(&self, input: U) -> ServiceRequest<U> {
-        ServiceRequest {
-            uri: self.uri.clone(),
-            method: self.method.clone(),
-            version: self.version,
-            headers: self.headers.clone(),
-            input,
-        }
+    /// Turn a protobuf service request into a byte-array service request
+    pub fn try_encode(&self) -> Result<ServiceRequest<Vec<u8>>, DBProstError> {
+        let mut body = Vec::new();
+        self.input.encode(&mut body)
+            .map(|v|
+                ServiceRequest {
+                    uri: self.uri.clone(),
+                    method: self.method.clone(),
+                    version: self.version,
+                    headers: self.headers.clone(),
+                    input: body,
+                })
+            .map_err(|e| DBProstError::ProstEncodeError(e))
     }
-}
 
-impl<T: Message + Default + 'static> From<T> for ServiceRequest<T> {
-    fn from(v: T) -> ServiceRequest<T> { ServiceRequest::new(v) }
+    /// Turn a protobuf service request into a hyper request
+    pub fn into_encoded_hyper(&self) -> Result<Request<Body>, DBProstError> {
+        self.try_encode().map(|v| v.into_hyper())
+    }
 }
 
 impl ServiceRequest<Vec<u8>> {
-    /// Turn a hyper request to a boxed future of a byte-array service request
-    pub fn from_hyper_raw(req: Request<Body>) -> BoxFutureReq<Vec<u8>> {
-        Box::pin(async move {
-            let uri = req.uri().clone();
-            let method = req.method().clone();
-            let version = req.version();
-            let headers = req.headers().clone();
-            let future_req = body::to_bytes(req.into_body()).await
-                .map_err(DBProstError::HyperError)
-                .map(move |body|
-                    ServiceRequest { uri, method, version, headers, input: body.to_vec() }
-                );
-            future_req
-        })
+    /// Turn a hyper request to ServiceRequest<Vec<u8>>
+    pub async fn try_from_hyper(req: Request<Body>) -> Result<ServiceRequest<Vec<u8>>, DBProstError> {
+        let uri = req.uri().clone();
+        let method = req.method().clone();
+        let version = req.version();
+        let headers = req.headers().clone();
+        body::to_bytes(req.into_body()).await
+            .map_err(DBProstError::HyperError)
+            .map(move |body| ServiceRequest { uri, method, version, headers, input: body.to_vec() })
     }
 
-    /// Turn a byte-array service request into a hyper request
-    pub fn to_hyper_raw(&self) -> Request<Body> {
+    /// Turn ServiceRequest<Vec<u8>> into a hyper request
+    pub fn into_hyper(&self) -> Request<Body> {
         let mut request = Request::builder()
             .method(self.method.clone())
             .uri(self.uri.clone())
@@ -85,47 +101,26 @@ impl ServiceRequest<Vec<u8>> {
         request
     }
 
-    /// Turn a byte-array service request into a `AfterBodyError`-wrapped version of the given error
-    pub fn body_err(&self, err: DBProstError) -> DBProstError {
-        DBProstError::AfterBodyError {
-            body: self.input.clone(),
-            method: Some(self.method.clone()),
-            version: self.version,
-            headers: self.headers.clone(),
-            status: None,
-            err: Box::new(err),
-        }
-    }
-
-    /// Serialize the byte-array service request into a protobuf service request
-    pub fn to_proto<T: Message + Default + 'static>(&self) -> Result<ServiceRequest<T>, DBProstError> {
-        match T::decode(self.input.as_ref()) {
-            Ok(v) => Ok(self.clone_with_input(v)),
-            Err(err) => Err(self.body_err(DBProstError::ProstDecodeError(err)))
-        }
+    /// try_decode ServiceRequest<Vec<u8>> whose input is protobuf data into a ServiceRequest<T>
+    pub fn try_decode<T: Message + Default + 'static>(&self) -> Result<ServiceRequest<T>, DBProstError> {
+        T::decode(self.input.as_ref())
+            .map(|v|
+                ServiceRequest {
+                    uri: self.uri.clone(),
+                    method: self.method.clone(),
+                    version: self.version,
+                    headers: self.headers.clone(),
+                    input:v,
+                })
+            .map_err(|e|
+                DBProstError::AfterBodyError {
+                    body: self.input.clone(),
+                    method: Some(self.method.clone()),
+                    version: self.version,
+                    headers: self.headers.clone(),
+                    status: None,
+                    err: Box::new(DBProstError::ProstDecodeError(e)),
+                })
     }
 }
 
-impl<T: Message + Default + 'static> ServiceRequest<T> {
-    /// Turn a protobuf service request into a byte-array service request
-    pub fn to_proto_raw(&self) -> Result<ServiceRequest<Vec<u8>>, DBProstError> {
-        let mut body = Vec::new();
-        if let Err(err) = self.input.encode(&mut body) {
-            Err(DBProstError::ProstEncodeError(err))
-        } else {
-            Ok(self.clone_with_input(body))
-        }
-    }
-
-    /// Turn a hyper request into a protobuf service request
-    pub fn from_hyper_proto(req: Request<Body>) -> BoxFutureReq<T> {
-        Box::pin(async move {
-            ServiceRequest::from_hyper_raw(req).await.and_then(|v| v.to_proto())
-        })
-    }
-
-    /// Turn a protobuf service request into a hyper request
-    pub fn to_hyper_proto(&self) -> Result<Request<Body>, DBProstError> {
-        self.to_proto_raw().map(|v| v.to_hyper_raw())
-    }
-}
\ No newline at end of file
diff --git a/xds/src/response.rs b/xds/src/response.rs
index b38db8b..96f02e6 100644
--- a/xds/src/response.rs
+++ b/xds/src/response.rs
@@ -1,6 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
 use hyper::{body, Body, Response, Version, header, StatusCode};
 use prost::{Message};
-use crate::util::*;
 use crate::error::*;
 
 
@@ -41,28 +57,23 @@ impl<T> ServiceResponse<T> {
     }
 }
 
-impl<T: Message + Default + 'static> From<T> for ServiceResponse<T> {
-    fn from(v: T) -> ServiceResponse<T> { ServiceResponse::new(v) }
-}
+// impl<T: Message + Default + 'static> From<T> for ServiceResponse<T> {
+//     fn from(v: T) -> ServiceResponse<T> { ServiceResponse::new(v) }
+// }
 
 impl ServiceResponse<Vec<u8>> {
     /// Turn a hyper response to a boxed future of a byte-array service response
-    pub fn from_hyper_raw(resp: Response<Body>) -> BoxFutureResp<Vec<u8>> {
-        Box::pin(async move {
-            let version = resp.version();
-            let headers = resp.headers().clone();
-            let status = resp.status().clone();
-            let future_resp = body::to_bytes(resp.into_body()).await
-                .map_err(DBProstError::HyperError)
-                .map(move |body|
-                    ServiceResponse { version, headers, status, output: body.to_vec() }
-                );
-            future_resp
-        })
+    pub async fn try_from_hyper(resp: Response<Body>) -> Result<ServiceResponse<Vec<u8>>, DBProstError> {
+        let version = resp.version();
+        let headers = resp.headers().clone();
+        let status = resp.status().clone();
+        body::to_bytes(resp.into_body()).await
+            .map_err(DBProstError::HyperError)
+            .map(move |body| ServiceResponse { version, headers, status, output: body.to_vec() })
     }
 
     /// Turn a byte-array service response into a hyper response
-    pub fn to_hyper_raw(&self) -> Response<Body> {
+    pub fn into_hyper(&self) -> Response<Body> {
         let mut resp = Response::builder()
             .status(StatusCode::OK)
             .body(Body::from(self.output.clone())).unwrap();
@@ -74,58 +85,55 @@ impl ServiceResponse<Vec<u8>> {
         resp
     }
 
-    /// Turn a byte-array service response into a `AfterBodyError`-wrapped version of the given error
-    pub fn body_err(&self, err: DBProstError) -> DBProstError {
-        DBProstError::AfterBodyError {
-            body: self.output.clone(),
-            method: None,
-            version: self.version,
-            headers: self.headers.clone(),
-            status: Some(self.status),
-            err: Box::new(err),
-        }
-    }
-
-
     /// Serialize the byte-array service response into a protobuf service response
-    pub fn to_proto<T: Message + Default + 'static>(&self) -> Result<ServiceResponse<T>, DBProstError> {
+    pub fn try_decode<T: Message + Default + 'static>(&self) -> Result<ServiceResponse<T>, DBProstError> {
         if self.status.is_success() {
-            match T::decode(self.output.as_ref()) {
-                Ok(v) => Ok(self.clone_with_output(v)),
-                Err(err) => Err(self.body_err(DBProstError::ProstDecodeError(err)))
-            }
+            T::decode(self.output.as_ref())
+                .map(|v|
+                    ServiceResponse {
+                        version: self.version,
+                        headers: self.headers.clone(),
+                        status: self.status.clone(),
+                        output: v,
+                    })
+                .map_err(|e|
+                    DBProstError::AfterBodyError {
+                        body: self.output.clone(),
+                        method: None,
+                        version: self.version,
+                        headers: self.headers.clone(),
+                        status: Some(self.status),
+                        err: Box::new(DBProstError::ProstDecodeError(e)),
+                    })
         } else {
-            match DBError::from_json_bytes(self.status, &self.output) {
-                Ok(err) => Err(self.body_err(DBProstError::DBWrapError(err))),
-                Err(err) => Err(self.body_err(DBProstError::JsonDecodeError(err)))
-            }
+            let err= DBError::new(self.status.clone(), "internal_err", "Internal Error");
+            Err(DBProstError::DBWrapError(err))
         }
     }
 }
 
 impl<T: Message + Default + 'static> ServiceResponse<T> {
-    /// Turn a protobuf service response into a byte-array service response
-    pub fn to_proto_raw(&self) -> Result<ServiceResponse<Vec<u8>>, DBProstError> {
+    pub fn try_encode(&self) -> Result<ServiceResponse<Vec<u8>>, DBProstError> {
         let mut body = Vec::new();
-        if let Err(err) = self.output.encode(&mut body) {
-            Err(DBProstError::ProstEncodeError(err))
-        } else {
-            Ok(self.clone_with_output(body))
-        }
+        self.output.encode(&mut body)
+            .map(|v|
+                ServiceResponse {
+                    version: self.version,
+                    headers: self.headers.clone(),
+                    status: self.status.clone(),
+                    output: body,
+                })
+            .map_err(|e| DBProstError::ProstEncodeError(e))
     }
 
-
     /// Turn a hyper response into a protobuf service response
-    pub async fn from_hyper_proto(resp: Response<Body>) -> Result<ServiceResponse<T>, DBProstError> {
-        // Box::pin(async move {
-        ServiceResponse::from_hyper_raw(resp).await.and_then(|v| v.to_proto())
-        // })
+    pub async fn decode_response(resp: Response<Body>) -> Result<ServiceResponse<T>, DBProstError> {
+        ServiceResponse::try_from_hyper(resp).await.and_then(|v| v.try_decode())
     }
 
-
     /// Turn a protobuf service response into a hyper response
-    pub fn to_hyper_proto(&self) -> Result<Response<Body>, DBProstError> {
-        self.to_proto_raw().map(|v| v.to_hyper_raw())
+    pub fn into_encoded_hyper(&self) -> Result<Response<Body>, DBProstError> {
+        self.try_encode().map(|v| v.into_hyper())
     }
 }
 
diff --git a/xds/src/server/.DS_Store b/xds/src/server/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/xds/src/server/.DS_Store differ
diff --git a/xds/src/server/server.rs b/xds/src/server/server.rs
index dd8930a..f27bc0a 100644
--- a/xds/src/server/server.rs
+++ b/xds/src/server/server.rs
@@ -16,14 +16,11 @@
  */
 
 use std::convert::Infallible;
-use std::env;
-use std::process::Output;
 use std::task::Poll;
-use hyper::client::service;
 use hyper::{Body, Request, Response, Server as hyper_server};
-use hyper::service::{make_service_fn, service_fn};
+use hyper::service::{ make_service_fn, service_fn };
 use tower::Service;
-use futures::future::{ ready, Ready, BoxFuture};
+use futures::future::{ ready, BoxFuture };
 use std::net::SocketAddr;
 use crate::protocol::message::*;
 
@@ -38,8 +35,16 @@ impl RpcServer {
         }
     }
 
-    pub async fn start(&self) {
+    pub async fn start<S>(&self, service: S)
+        where
+            S: Service<Request<Body>, Response = Response<Body>, Error = Infallible>
+            + Clone
+            + Send
+            + 'static,
+            S::Future: Send + 'static,
+    {
         env_logger::init();
+
         let make_service = make_service_fn(|_conn| async {
             let svc = RPCHandler;
             Ok::<_, Infallible>(svc)
diff --git a/xds/src/util.rs b/xds/src/util.rs
index 2fbe3f3..39374fb 100644
--- a/xds/src/util.rs
+++ b/xds/src/util.rs
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
 use futures::future::BoxFuture;
 use crate::request::ServiceRequest;
 use crate::response::ServiceResponse;
diff --git a/xds/src/wrapper.rs b/xds/src/wrapper.rs
deleted file mode 100644
index b80ffa8..0000000
--- a/xds/src/wrapper.rs
+++ /dev/null
@@ -1,110 +0,0 @@
-use std::sync::Arc;
-use std::task::Poll;
-use futures::future::BoxFuture;
-
-use hyper::{Body, Request, Response, header, StatusCode};
-
-use hyper::client::conn::Builder;
-use hyper::client::connect::HttpConnector;
-use hyper::client::service::Connect;
-
-use tower::Service;
-use prost::{Message};
-
-use crate::request::ServiceRequest;
-use crate::response::ServiceResponse;
-use crate::util::*;
-use crate::error::*;
-
-
-
-/// A wrapper for a hyper client
-#[derive(Debug)]
-pub struct HyperClient {
-    /// The hyper client
-    /// The root URL without any path attached
-    pub root_url: String,
-}
-
-impl HyperClient {
-    /// Create a new client wrapper for the given client and root using protobuf
-    pub fn new(root_url: &str) -> HyperClient {
-        HyperClient {
-            root_url: root_url.trim_end_matches('/').to_string(),
-        }
-    }
-
-    // Invoke the given request for the given path and return a boxed future result
-    pub async fn request<I, O>(&self, path: &str, req: ServiceRequest<I>) -> Result<ServiceResponse<O>, DBProstError>
-        where I: Message + Default + 'static, O: Message + Default + 'static {
-        let hyper_req = req.to_hyper_proto().unwrap();
-        let mut hyper_connect = Connect::new(HttpConnector::new(), Builder::new());
-
-        let url_string = format!("{}/{}", self.root_url, path.trim_start_matches('/'));
-        let uri = url_string.parse::<hyper::Uri>().unwrap();
-
-        let mut req_to_send = hyper_connect.call(uri.clone()).await.map_err(DBProstError::HyperError).unwrap();
-
-        let hyper_resp = req_to_send.call(hyper_req).await.map_err(DBProstError::HyperError).unwrap();
-        ServiceResponse::from_hyper_proto(hyper_resp).await
-    }
-}
-
-/// Service for taking a raw service request and returning a boxed future of a raw service response
-pub trait HyperService {
-    /// Accept a raw service request and return a boxed future of a raw service response
-    fn handle(&self, req: ServiceRequest<Vec<u8>>) -> BoxFutureResp<Vec<u8>>;
-}
-
-/// A wrapper for a `HyperService` trait that keeps a `Arc` version of the service
-pub struct HyperServer<T> {
-    /// The `Arc` version of the service
-    ///
-    /// Needed because of [hyper Service lifetimes](https://github.com/tokio-rs/tokio-service/issues/9)
-    pub service: Arc<T>,
-}
-
-impl<T> HyperServer<T> {
-    /// Create a new service wrapper for the given impl
-    pub fn new(service: T) -> HyperServer<T> { HyperServer { service: Arc::new(service) } }
-}
-
-impl<T> Service<Request<Body>> for HyperServer<T>
-    where T: 'static + Send + Sync + HyperService
-{
-    type Response = Response<Body>;
-    type Error = hyper::Error;
-    type Future = BoxFuture<'static, Result<Self::Response, Self::Error>>;
-
-    fn poll_ready(&mut self, cx: &mut std::task::Context<'_>) -> Poll<Result<(), Self::Error>> {
-        Poll::Ready(Ok(()))
-    }
-
-    fn call(&mut self, req: Request<Body>) -> Self::Future {
-        let content_type = req.headers().get(header::CONTENT_TYPE).unwrap().to_str().unwrap();
-        if content_type == "application/protobuf" {
-            Box::pin(async move {
-                let status = StatusCode::UNSUPPORTED_MEDIA_TYPE;
-                Ok(DBError::new(status, "bad_content_type", "Content type must be application/protobuf").to_hyper_resp())
-            })
-        } else {
-            let service = self.service.clone();
-            Box::pin(async move {
-                let request = ServiceRequest::from_hyper_raw(req).await;
-                let resp = service.handle(request.unwrap()).await;
-                resp.map(|v| v.to_hyper_raw())
-                    .or_else(|err| match err.root_err() {
-                        DBProstError::ProstDecodeError(_) =>
-                            Ok(DBError::new(StatusCode::BAD_REQUEST, "protobuf_decode_err", "Invalid protobuf body").
-                                to_hyper_resp()),
-                        DBProstError::DBWrapError(err) =>
-                            Ok(err.to_hyper_resp()),
-                        DBProstError::HyperError(err) =>
-                            Err(err),
-                        _ => Ok(DBError::new(StatusCode::INTERNAL_SERVER_ERROR, "internal_err", "Internal Error").
-                            to_hyper_resp()),
-                    })
-            })
-        }
-    }
-}
\ No newline at end of file


[dubbo-rust] 18/35: Ftr: add license check github action.

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 61d6a0da212ca6e83b6a4cebfbbcc51f484e9eb4
Author: Zonglei Dong <do...@apache.org>
AuthorDate: Sat May 14 15:28:21 2022 +0800

    Ftr: add license check github action.
---
 .github/workflows/licence-checker.yml | 45 ++++++++++++++++++++++
 .licenserc.yaml                       | 72 +++++++++++++++++++++++++++++++++++
 2 files changed, 117 insertions(+)

diff --git a/.github/workflows/licence-checker.yml b/.github/workflows/licence-checker.yml
new file mode 100644
index 0000000..0caf87d
--- /dev/null
+++ b/.github/workflows/licence-checker.yml
@@ -0,0 +1,45 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+#
+
+name: License checker
+
+on:
+  push:
+    branches:
+      - main
+  pull_request:
+    branches:
+      - main
+  pull_request_target:
+    branches:
+      - main
+
+jobs:
+  check-license:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Check License Header
+        uses: apache/skywalking-eyes@main
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          log: info
+          config: .licenserc.yaml
diff --git a/.licenserc.yaml b/.licenserc.yaml
new file mode 100644
index 0000000..bdecd85
--- /dev/null
+++ b/.licenserc.yaml
@@ -0,0 +1,72 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+#
+
+header: # `header` section is configurations for source codes license header.
+  license:
+    spdx-id: Apache-2.0 # the spdx id of the license, it's convenient when your license is standard SPDX license.
+    copyright-owner: Apache Software Foundation # the copyright owner to replace the [owner] in the `spdx-id` template.
+    content: | # `license` will be used as the content when `fix` command needs to insert a license header.
+      Licensed to the Apache Software Foundation (ASF) under one or more
+      contributor license agreements.  See the NOTICE file distributed with
+      this work for additional information regarding copyright ownership.
+      The ASF licenses this file to You 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.
+    # `pattern` is optional regexp if all the file headers are the same as `license` or the license of `spdx-id` and `copyright-owner`.
+    pattern: |
+      Licensed to the Apache Software Foundation under one or more contributor
+      license agreements. See the NOTICE file distributed with
+      this work for additional information regarding copyright
+      ownership. The Apache Software Foundation licenses this file to you 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.
+  paths: # `paths` are the path list that will be checked (and fixed) by license-eye, default is ['**'].
+    - '**'
+
+  paths-ignore: # `paths-ignore` are the path list that will be ignored by license-eye.
+    - '**/*.md'
+    - '**/Cargo.toml'
+    - 'LICENSE'
+    - 'NOTICE'
+    - '.asf.yml'
+    - '.gitignore'
+    - '.github'
+  comment: on-failure # on what condition license-eye will comment on the pull request, `on-failure`, `always`, `never`.
+
+  # license-location-threshold specifies the index threshold where the license header can be located,
+  # after all, a "header" cannot be TOO far from the file start.
+  license-location-threshold: 80
+
+dependency:
+  files:
+    - Cargo.toml


[dubbo-rust] 15/35: Fix spell mistake #9

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 2b2eef47ce8c691d195c622a0c3ba6e665a4c050
Merge: 1f5fb8e 291a41b
Author: ken.lj <ke...@gmail.com>
AuthorDate: Sat May 14 10:19:58 2022 +0800

    Fix spell mistake #9

 .github/workflows/CI.yml | 10 +---------
 .gitignore               |  3 +++
 2 files changed, 4 insertions(+), 9 deletions(-)


[dubbo-rust] 06/35: Mod: empty examples src

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit b630a29995480e5537e7223cfe53d4360772cefb
Author: johankoi <jo...@163.com>
AuthorDate: Mon Apr 25 15:35:30 2022 +0800

    Mod: empty  examples src
    
    Signed-off-by: johankoi <jo...@163.com>
---
 examples/Cargo.toml                        | 38 ------------------------------
 examples/build.rs                          |  0
 examples/proto/helloworld/helloworld.proto | 37 -----------------------------
 examples/src/grpc-web/client.rs            |  0
 examples/src/grpc-web/server.rs            |  0
 examples/src/helloworld/client.rs          |  0
 examples/src/helloworld/server.rs          |  0
 examples/src/helloworld/server_blocking.rs |  0
 8 files changed, 75 deletions(-)

diff --git a/examples/Cargo.toml b/examples/Cargo.toml
deleted file mode 100644
index a477bf0..0000000
--- a/examples/Cargo.toml
+++ /dev/null
@@ -1,38 +0,0 @@
-[package]
-name = "examples"
-publish = false
-version = "0.1.0"
-edition = "2022"
-
-[[bin]]
-name = "helloworld-server"
-path = "src/helloworld/server.rs"
-
-[[bin]]
-name = "helloworld-client"
-path = "src/helloworld/client.rs"
-
-[[bin]]
-name = "grpc-web-server"
-path = "src/grpc-web/server.rs"
-
-[[bin]]
-name = "grpc-web-client"
-path = "src/grpc-web/client.rs"
-
-[dependencies]
-async-stream = "0.3"
-futures = { version = "0.3", default-features = false, features = ["alloc"] }
-prost = "0.10"
-tokio = { version = "1.0", features = [ "rt-multi-thread", "time", "fs", "macros", "net",] }
-tokio-stream = { version = "0.1", features = ["net"] }
-# Required for wellknown types
-prost-types = "0.10"
-# grpc-web example
-bytes = "1"
-tokio-rustls = "*"
-hyper-rustls = { version = "0.23", features = ["http2"] }
-rustls-pemfile = "*"
-tower-http = { version = "0.2", features = ["add-extension"] }
-
-[build-dependencies]
diff --git a/examples/build.rs b/examples/build.rs
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/proto/helloworld/helloworld.proto b/examples/proto/helloworld/helloworld.proto
deleted file mode 100644
index 8de5d08..0000000
--- a/examples/proto/helloworld/helloworld.proto
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2015 gRPC authors.
-//
-// 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.
-
-syntax = "proto3";
-
-option java_multiple_files = true;
-option java_package = "io.grpc.examples.helloworld";
-option java_outer_classname = "HelloWorldProto";
-
-package helloworld;
-
-// The greeting service definition.
-service Greeter {
-  // Sends a greeting
-  rpc SayHello (HelloRequest) returns (HelloReply) {}
-}
-
-// The request message containing the user's name.
-message HelloRequest {
-  string name = 1;
-}
-
-// The response message containing the greetings
-message HelloReply {
-  string message = 1;
-}
\ No newline at end of file
diff --git a/examples/src/grpc-web/client.rs b/examples/src/grpc-web/client.rs
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/src/grpc-web/server.rs b/examples/src/grpc-web/server.rs
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/src/helloworld/client.rs b/examples/src/helloworld/client.rs
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/src/helloworld/server.rs b/examples/src/helloworld/server.rs
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/src/helloworld/server_blocking.rs b/examples/src/helloworld/server_blocking.rs
deleted file mode 100644
index e69de29..0000000


[dubbo-rust] 35/35: Merge pull request #20 from Johankoi/main

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 7dcc16219291ba29dabe63ef674966a4ea7b8eda
Merge: 69249f0 bd85362
Author: ken.lj <ke...@gmail.com>
AuthorDate: Sat Jul 23 22:44:17 2022 +0800

    Merge pull request #20 from Johankoi/main
    
    finish 1.0.0

 Cargo.toml                                  |   3 +
 README.md                                   |  43 ++-
 README_CN.md                                |  42 +++
 dubbo-build/Cargo.toml                      |  12 +
 dubbo-build/src/generator.rs                | 184 +++++++++++
 {xds => dubbo-build}/src/lib.rs             |  14 +-
 examples/grpc-gen/Cargo.toml                |  32 ++
 examples/grpc-gen/build.rs                  |  11 +
 examples/grpc-gen/pb/greeter.proto          |  14 +
 examples/grpc-gen/src/client.rs             |  10 +
 examples/grpc-gen/src/greeter.rs            |  97 ++++++
 examples/grpc-gen/src/lib.rs                |   6 +
 examples/grpc-gen/src/server.rs             |  38 +++
 examples/protobuf-transport/Cargo.toml      |  30 ++
 examples/protobuf-transport/build.rs        |   9 +
 examples/protobuf-transport/pb/person.proto |  26 ++
 examples/protobuf-transport/src/client.rs   |  33 ++
 examples/protobuf-transport/src/lib.rs      |   7 +
 examples/protobuf-transport/src/person.rs   |  35 ++
 examples/protobuf-transport/src/server.rs   |  11 +
 xds/Cargo.toml                              |  22 ++
 xds/src/client/client.rs                    |  90 ++++++
 xds/src/client/mod.rs                       |   4 +
 xds/src/error.rs                            | 153 +++++++++
 xds/src/lib.rs                              |  30 +-
 xds/src/protocol/error.rs                   | 206 ++++++++++++
 xds/src/protocol/message.rs                 | 485 ++++++++++++++++++++++++++++
 xds/src/{client => protocol}/mod.rs         |   7 +
 xds/src/request.rs                          | 126 ++++++++
 xds/src/response.rs                         | 139 ++++++++
 xds/src/server/mod.rs                       |   4 +
 xds/src/server/server.rs                    |  75 +++++
 xds/src/{lib.rs => util.rs}                 |  17 +-
 33 files changed, 1996 insertions(+), 19 deletions(-)


[dubbo-rust] 07/35: Init basic project structure (#3)

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 28eab63e6b454a70d869d0525ab20f0df68dfa92
Merge: 961471b b630a29
Author: ken.lj <ke...@gmail.com>
AuthorDate: Tue Apr 26 11:32:07 2022 +0800

    Init basic project structure (#3)

 .gitignore                   |   2 +
 Cargo.toml                   |   9 ++
 LICENSE                      | 191 +++++++++++++++++++++++++++++++++++++++++++
 README_CN.md                 |   0
 common/Cargo.toml            |   8 ++
 common/src/lib.rs            |   8 ++
 config/Cargo.toml            |   8 ++
 config/src/lib.rs            |   8 ++
 contributing.md              |  31 +++++++
 examples/LICENSE             | 191 +++++++++++++++++++++++++++++++++++++++++++
 examples/README.md           |   0
 examples/example-tutorial.md |   0
 metadata/Cargo.toml          |   8 ++
 metadata/src/lib.rs          |   8 ++
 protocol/Cargo.toml          |   8 ++
 protocol/src/lib.rs          |   8 ++
 registry/Cargo.toml          |   8 ++
 registry/src/lib.rs          |   8 ++
 xds/Cargo.toml               |   8 ++
 xds/src/client/client.rs     |   0
 xds/src/client/mod.rs        |   0
 xds/src/lib.rs               |   8 ++
 xds/src/server/mod.rs        |   0
 xds/src/server/server.rs     |   0
 24 files changed, 520 insertions(+)


[dubbo-rust] 32/35: Update server.rs

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit dae80cd98bc16fa0a738c9632caecc815fde2269
Author: Johankoi <Jo...@163.com>
AuthorDate: Thu Jul 21 17:18:28 2022 +0800

    Update server.rs
    
    port modify
---
 examples/protobuf-transport/src/server.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/examples/protobuf-transport/src/server.rs b/examples/protobuf-transport/src/server.rs
index 9b0c443..7fe5aa7 100644
--- a/examples/protobuf-transport/src/server.rs
+++ b/examples/protobuf-transport/src/server.rs
@@ -4,8 +4,8 @@ use xds::{ server::RpcServer };
 
 #[tokio::main]
 async fn main() {
-    let addr = SocketAddr::from(([127, 0, 0, 1], 8972));
+    let addr = SocketAddr::from(([127, 0, 0, 1], 8975));
     let server = RpcServer::new(addr);
     server.start().await;
     println!("RpcServer ok");
-}
\ No newline at end of file
+}


[dubbo-rust] 01/35: first commit

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 9e46c77e84ac8c4a51516c0e80bf170d15fbb6af
Author: ken.lj <ke...@gmail.com>
AuthorDate: Sun Apr 3 11:26:36 2022 +0800

    first commit
---
 README.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..f39d9ab
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+# dubbo-rust


[dubbo-rust] 22/35: feat: protobuf example

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 3a8b693202320650fe138aed80bc656677b635ab
Author: johankoi <jo...@163.com>
AuthorDate: Wed Jun 15 00:47:16 2022 +0800

    feat: protobuf example
    
    Signed-off-by: johankoi <jo...@163.com>
---
 Cargo.toml                                         |  1 +
 examples/protobuf/client/Cargo.toml                |  3 ++
 examples/protobuf/client/src/main.rs               | 19 +++++++++--
 .../protobuf/{client => pb_message}/Cargo.toml     |  8 +++--
 examples/protobuf/pb_message/build.rs              | 18 +++++++++++
 examples/protobuf/pb_message/pb/greeter.proto      | 14 ++++++++
 examples/protobuf/pb_message/pb/person.proto       | 26 +++++++++++++++
 examples/protobuf/pb_message/src/lib.rs            | 37 ++++++++++++++++++++++
 examples/protobuf/pb_message/src/pb/greeter.rs     | 10 ++++++
 examples/protobuf/pb_message/src/pb/mod.rs         |  5 +++
 examples/protobuf/pb_message/src/pb/person.rs      | 35 ++++++++++++++++++++
 xds/src/client/client.rs                           | 11 ++++---
 xds/src/lib.rs                                     |  2 +-
 xds/src/server/server.rs                           |  5 +--
 14 files changed, 181 insertions(+), 13 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index f73b8c4..0fe1fd2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,4 +8,5 @@ members = [
   "config",
   "examples/protobuf/client",
   "examples/protobuf/server",
+  "examples/protobuf/pb_message",
 ]
\ No newline at end of file
diff --git a/examples/protobuf/client/Cargo.toml b/examples/protobuf/client/Cargo.toml
index b0bbc6e..e4c426c 100644
--- a/examples/protobuf/client/Cargo.toml
+++ b/examples/protobuf/client/Cargo.toml
@@ -8,4 +8,7 @@ edition = "2021"
 [dependencies]
 xds = { version = "0.1.0", path = "../../../xds" }
 tokio = {version = "1.9.0", features = ["full"]}
+pb_message =  { version = "0.1.0", path = "../pb_message" }
+prost = "0.10.4"
+hyper = { version = "0.14", features = ["full"] }
 
diff --git a/examples/protobuf/client/src/main.rs b/examples/protobuf/client/src/main.rs
index 0ae5d6a..bd6507f 100644
--- a/examples/protobuf/client/src/main.rs
+++ b/examples/protobuf/client/src/main.rs
@@ -1,16 +1,31 @@
 use std::collections::hash_map::HashMap;
 use xds::{ client::RpcClient };
+use pb_message::pb::person::Person;
+use prost::Message;
+use hyper::body::Buf;
 
 #[tokio::main]
 async fn main() {
     let task = tokio::spawn(async move {
         let mut client = RpcClient::new(String::from("http://127.0.0.1:8972"));
 
-        println!("client call begin");
         let service_path = String::from("helloworld");
         let service_method = String::from("hello");
         let metadata = HashMap::new();
-        client.call(service_path, service_method, &metadata).await;
+
+        let mut person = Person::default();
+        person.name = "guomiwu".to_string();
+        let pbData = person.encode_to_vec();
+
+        let callResult = client.call(service_path, service_method, &metadata, pbData).await;
+        let resp = callResult.unwrap();
+
+        //  asynchronously aggregate the chunks of the body
+        let body = hyper::body::aggregate(resp).await;
+        let data = body.unwrap().chunk().to_vec();
+
+        let resPerson = Person::decode(data.as_ref()).unwrap();
+        println!("resPerson={:?}", resPerson.name);
 
     });
     task.await.unwrap();
diff --git a/examples/protobuf/client/Cargo.toml b/examples/protobuf/pb_message/Cargo.toml
similarity index 57%
copy from examples/protobuf/client/Cargo.toml
copy to examples/protobuf/pb_message/Cargo.toml
index b0bbc6e..f4a97cd 100644
--- a/examples/protobuf/client/Cargo.toml
+++ b/examples/protobuf/pb_message/Cargo.toml
@@ -1,11 +1,13 @@
 [package]
-name = "protobuf"
+name = "pb_message"
 version = "0.1.0"
 edition = "2021"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-xds = { version = "0.1.0", path = "../../../xds" }
-tokio = {version = "1.9.0", features = ["full"]}
+prost = "0.10.4"
+prost-types = "0.10.1"
 
+[build-dependencies]
+prost-build = "0.10.4"
\ No newline at end of file
diff --git a/examples/protobuf/pb_message/build.rs b/examples/protobuf/pb_message/build.rs
new file mode 100644
index 0000000..a198077
--- /dev/null
+++ b/examples/protobuf/pb_message/build.rs
@@ -0,0 +1,18 @@
+use std::io::Result;
+use prost_build::Config;
+
+fn main() -> Result<()> {
+
+    Config::new()
+        .out_dir("src/pb")
+        .compile_protos(&["pb/person.proto"], &["pb/"])?;
+
+    // println!("cargo:rerun-if-changed=pb/greeter_rpc.pb");
+    // println!("cargo:rerun-if-changed=pb/build.rs");
+
+    Config::new()
+        .out_dir("src/pb")
+        .compile_protos(&["pb/greeter.proto"], &["pb/"])?;
+
+    Ok(())
+}
\ No newline at end of file
diff --git a/examples/protobuf/pb_message/pb/greeter.proto b/examples/protobuf/pb_message/pb/greeter.proto
new file mode 100644
index 0000000..0d7f9fc
--- /dev/null
+++ b/examples/protobuf/pb_message/pb/greeter.proto
@@ -0,0 +1,14 @@
+syntax = "proto3";
+package greeter;
+
+message HelloRequest {
+  string name = 1;
+}
+
+message HelloResponse {
+  string message = 1;
+}
+
+service Greeter {
+  rpc SayHello (HelloRequest) returns (HelloResponse);
+}
\ No newline at end of file
diff --git a/examples/protobuf/pb_message/pb/person.proto b/examples/protobuf/pb_message/pb/person.proto
new file mode 100644
index 0000000..d322c14
--- /dev/null
+++ b/examples/protobuf/pb_message/pb/person.proto
@@ -0,0 +1,26 @@
+syntax = "proto3";
+package person;
+
+message Person {
+  string name = 1;
+  int32 id = 2;  // Unique ID number for this person.
+  string email = 3;
+
+  enum PhoneType {
+    MOBILE = 0;
+    HOME = 1;
+    WORK = 2;
+  }
+
+  message PhoneNumber {
+    string number = 1;
+    PhoneType type = 2;
+  }
+
+  repeated PhoneNumber phones = 4;
+}
+
+// Our address book file is just one of these.
+message AddressBook {
+  repeated Person people = 1;
+}
\ No newline at end of file
diff --git a/examples/protobuf/pb_message/src/lib.rs b/examples/protobuf/pb_message/src/lib.rs
new file mode 100644
index 0000000..3a90aed
--- /dev/null
+++ b/examples/protobuf/pb_message/src/lib.rs
@@ -0,0 +1,37 @@
+
+pub mod pb;
+
+#[cfg(test)]
+mod tests {
+    use crate::pb::Person;
+    use crate::pb::greeter;
+
+    use std::io::Cursor;
+    use prost::Message;
+
+    pub fn create_hello_request(name: String) -> greeter::HelloRequest {
+        let mut hello_request = greeter::HelloRequest::default();
+        hello_request.name = name;
+        hello_request
+    }
+
+    pub fn serialize_greeter(hello: &greeter::HelloRequest) -> Vec<u8> {
+        let mut buf = Vec::new();
+        buf.reserve(hello.encoded_len());
+
+        hello.encode(&mut buf).unwrap();
+        buf
+    }
+
+
+    // pub fn deserialize_greeter(buf: &[u8]) -> Result<greeter::HelloRequest, prost::DecodeError> {
+    //     greeter::HelloRequest::decode(&mut Cursor::new(buf))
+    // }
+
+    #[test]
+    fn it_works() {
+        let person = Person::default();
+        person.encode_to_vec();
+        println!("{person:?}");
+    }
+}
diff --git a/examples/protobuf/pb_message/src/pb/greeter.rs b/examples/protobuf/pb_message/src/pb/greeter.rs
new file mode 100644
index 0000000..36aa34d
--- /dev/null
+++ b/examples/protobuf/pb_message/src/pb/greeter.rs
@@ -0,0 +1,10 @@
+#[derive(Clone, PartialEq, ::prost::Message)]
+pub struct HelloRequest {
+    #[prost(string, tag="1")]
+    pub name: ::prost::alloc::string::String,
+}
+#[derive(Clone, PartialEq, ::prost::Message)]
+pub struct HelloResponse {
+    #[prost(string, tag="1")]
+    pub message: ::prost::alloc::string::String,
+}
diff --git a/examples/protobuf/pb_message/src/pb/mod.rs b/examples/protobuf/pb_message/src/pb/mod.rs
new file mode 100644
index 0000000..8c11e43
--- /dev/null
+++ b/examples/protobuf/pb_message/src/pb/mod.rs
@@ -0,0 +1,5 @@
+pub mod person;
+pub mod greeter;
+
+pub use person::*;
+pub use greeter::*;
\ No newline at end of file
diff --git a/examples/protobuf/pb_message/src/pb/person.rs b/examples/protobuf/pb_message/src/pb/person.rs
new file mode 100644
index 0000000..c45d257
--- /dev/null
+++ b/examples/protobuf/pb_message/src/pb/person.rs
@@ -0,0 +1,35 @@
+#[derive(Clone, PartialEq, ::prost::Message)]
+pub struct Person {
+    #[prost(string, tag="1")]
+    pub name: ::prost::alloc::string::String,
+    /// Unique ID number for this person.
+    #[prost(int32, tag="2")]
+    pub id: i32,
+    #[prost(string, tag="3")]
+    pub email: ::prost::alloc::string::String,
+    #[prost(message, repeated, tag="4")]
+    pub phones: ::prost::alloc::vec::Vec<person::PhoneNumber>,
+}
+/// Nested message and enum types in `Person`.
+pub mod person {
+    #[derive(Clone, PartialEq, ::prost::Message)]
+    pub struct PhoneNumber {
+        #[prost(string, tag="1")]
+        pub number: ::prost::alloc::string::String,
+        #[prost(enumeration="PhoneType", tag="2")]
+        pub r#type: i32,
+    }
+    #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
+    #[repr(i32)]
+    pub enum PhoneType {
+        Mobile = 0,
+        Home = 1,
+        Work = 2,
+    }
+}
+/// Our address book file is just one of these.
+#[derive(Clone, PartialEq, ::prost::Message)]
+pub struct AddressBook {
+    #[prost(message, repeated, tag="1")]
+    pub people: ::prost::alloc::vec::Vec<Person>,
+}
diff --git a/xds/src/client/client.rs b/xds/src/client/client.rs
index 4cad8f3..1387e36 100644
--- a/xds/src/client/client.rs
+++ b/xds/src/client/client.rs
@@ -19,7 +19,7 @@ use hyper::client::conn::Builder;
 use hyper::client::connect::HttpConnector;
 use hyper::client::service::Connect;
 use hyper::service::Service;
-use hyper::{Body, Request};
+use hyper::{Body, Request, Response};
 
 use crate::protocol::message::*;
 use std::collections::HashMap;
@@ -40,8 +40,9 @@ impl RpcClient {
         &mut self,
         service_path: String,
         service_method: String,
-        metadata: &Metadata
-    ) -> std::result::Result<(), Box<dyn std::error::Error + Send + Sync>>
+        metadata: &Metadata,
+        payload: Vec<u8>
+    ) -> std::result::Result<Response<Body>, Box<dyn std::error::Error + Send + Sync>>
     {
         let mut req = Message::new();
         req.set_version(0);
@@ -50,6 +51,7 @@ impl RpcClient {
         req.set_compress_type(CompressType::Gzip);
         req.service_path = service_path;
         req.service_method = service_method;
+        req.payload = payload;
 
         let mut new_metadata = HashMap::with_capacity(metadata.len());
         for (k, v) in metadata {
@@ -67,9 +69,8 @@ impl RpcClient {
         let body = Body::from(body_data);
         let req = Request::get(uri.clone()).body(body)?;
         let res = svc.call(req).await?;
-        println!("RESPONSE={:?}", res.body());
 
-        Ok(())
+        Ok(res)
     }
 }
 
diff --git a/xds/src/lib.rs b/xds/src/lib.rs
index 736d111..4f818f9 100644
--- a/xds/src/lib.rs
+++ b/xds/src/lib.rs
@@ -17,7 +17,7 @@
 
 pub mod client;
 pub mod server;
-mod protocol;
+pub mod protocol;
 
 #[cfg(test)]
 mod tests {
diff --git a/xds/src/server/server.rs b/xds/src/server/server.rs
index be343fb..dd8930a 100644
--- a/xds/src/server/server.rs
+++ b/xds/src/server/server.rs
@@ -70,22 +70,23 @@ impl Service<Request<Body>> for RPCHandler {
     fn call(&mut self, req: Request<Body>) -> Self::Future {
         Box::pin(async move {
             let whole_body = hyper::body::to_bytes(req.into_body()).await.unwrap();
-
             let mut msg = Message::new();
             let mut data = &whole_body[..];
 
+            let mut resp = ready(Ok(Response::new(Body::from("hello world with tower service! \n")))).await;
             match msg.decode(&mut data) {
                 Ok(()) => {
                     let service_path = &msg.service_path;
                     let service_method = &msg.service_method;
                     let key = format!("{}.{}", service_path, service_method);
+                    println!("{:?}", msg.payload);
                     println!("recieved request success, and body message decode key is: {:?}", key);
+                    resp = ready(Ok(Response::new(Body::from(msg.payload)))).await;
                 }
                 Err(err) => {
                     eprintln!("failed to read: {}", err.to_string());
                 }
             }
-            let resp = ready(Ok(Response::new(Body::from("hello world with tower service! \n")))).await;
             resp
         })
     }


[dubbo-rust] 34/35: .DS_Store banished!

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit bd853626c2f9af3efb1f7b3a86b0c897dad24148
Author: hxq <jo...@163.com>
AuthorDate: Thu Jul 21 21:25:22 2022 +0800

    .DS_Store banished!
---
 .github/.DS_Store               | Bin 6148 -> 0 bytes
 dubbo-build/.DS_Store           | Bin 6148 -> 0 bytes
 examples/.DS_Store              | Bin 6148 -> 0 bytes
 examples/grpc-gen/.DS_Store     | Bin 6148 -> 0 bytes
 examples/grpc-gen/src/.DS_Store | Bin 6148 -> 0 bytes
 xds/src/.DS_Store               | Bin 6148 -> 0 bytes
 xds/src/server/.DS_Store        | Bin 6148 -> 0 bytes
 7 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/.github/.DS_Store b/.github/.DS_Store
deleted file mode 100644
index 3bb81dc..0000000
Binary files a/.github/.DS_Store and /dev/null differ
diff --git a/dubbo-build/.DS_Store b/dubbo-build/.DS_Store
deleted file mode 100644
index cd16f51..0000000
Binary files a/dubbo-build/.DS_Store and /dev/null differ
diff --git a/examples/.DS_Store b/examples/.DS_Store
deleted file mode 100644
index 0d3b142..0000000
Binary files a/examples/.DS_Store and /dev/null differ
diff --git a/examples/grpc-gen/.DS_Store b/examples/grpc-gen/.DS_Store
deleted file mode 100644
index b57983e..0000000
Binary files a/examples/grpc-gen/.DS_Store and /dev/null differ
diff --git a/examples/grpc-gen/src/.DS_Store b/examples/grpc-gen/src/.DS_Store
deleted file mode 100644
index 5008ddf..0000000
Binary files a/examples/grpc-gen/src/.DS_Store and /dev/null differ
diff --git a/xds/src/.DS_Store b/xds/src/.DS_Store
deleted file mode 100644
index 05fc01e..0000000
Binary files a/xds/src/.DS_Store and /dev/null differ
diff --git a/xds/src/server/.DS_Store b/xds/src/server/.DS_Store
deleted file mode 100644
index 5008ddf..0000000
Binary files a/xds/src/server/.DS_Store and /dev/null differ


[dubbo-rust] 17/35: Fix: fix file license header format.

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 8fe7044cd86d0bb5dd07d51cd0ff8fb5cd58a813
Author: Zonglei Dong <do...@apache.org>
AuthorDate: Sat May 14 15:28:08 2022 +0800

    Fix: fix file license header format.
---
 .asf.yaml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/.asf.yaml b/.asf.yaml
index 11f9b19..9cc0f3d 100644
--- a/.asf.yaml
+++ b/.asf.yaml
@@ -1,5 +1,4 @@
 #
-#
 #   Licensed to the Apache Software Foundation (ASF) under one or more
 #   contributor license agreements.  See the NOTICE file distributed with
 #   this work for additional information regarding copyright ownership.
@@ -15,7 +14,6 @@
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
 #
-#
 
 notifications:
   commits:      commits@dubbo.apache.org


[dubbo-rust] 10/35: Update CI.yml

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 04a3e3f0fb9ed4e8a633f4359ec503d523ed0b09
Author: Johankoi <Jo...@163.com>
AuthorDate: Wed Apr 27 00:28:44 2022 +0800

    Update CI.yml
    
    fix work flow
---
 .github/workflows/CI.yml | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index 993dbd7..b377439 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -27,7 +27,7 @@ jobs:
     - uses: actions-rs/toolchain@v1
       with:
           toolchain: ${{ matrix.rust }}
-    - run: cargo che
+    - run: cargo check
     
  fmt:
     name: Rustfmt
@@ -41,9 +41,7 @@ jobs:
       - uses: actions/checkout@main
       - uses: actions-rs/toolchain@v1
         with:
-          profile: minimal
-          toolchain: stable
-          override: true
+          toolchain: ${{ matrix.rust }}
       - run: rustup component add rustfmt
       - run: cargo fmt --all -- --check
       


[dubbo-rust] 05/35: Doc: fix

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch poc-idl
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git

commit 336a9a0381ff0d5cf6a176f58422c16fa82a87b0
Author: hanxiaoqing <ha...@rongcloud.cn>
AuthorDate: Mon Apr 25 15:20:02 2022 +0800

    Doc: fix
    
    Signed-off-by: hanxiaoqing <ha...@rongcloud.cn>
---
 contributing.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contributing.md b/contributing.md
index b1265c2..dc3c587 100644
--- a/contributing.md
+++ b/contributing.md
@@ -1,4 +1,4 @@
-Contributing to Dubbogo
+Contributing to dubbo-rust
 
 ## 1. Branch