-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #642 from chickenlj/new-triple-samples-helloworld
Polish helloworld
- Loading branch information
Showing
17 changed files
with
280 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
header: | ||
license: | ||
spdx-id: Apache-2.0 | ||
content: | | ||
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. | ||
paths-ignore: | ||
- '**/*.versionsBackup' | ||
- '**/.idea/' | ||
- '**/*.iml' | ||
- '**/.settings/*' | ||
- '**/.classpath' | ||
- '**/.project' | ||
- '**/target/**' | ||
- '**/generated/**' | ||
- '**/*.log' | ||
- '**/codestyle/*' | ||
- '**/resources/META-INF/**' | ||
- '**/resources/mockito-extensions/**' | ||
- '**/*.proto' | ||
- '**/*.cache' | ||
- '**/*.txt' | ||
- '**/*.load' | ||
- '**/*.flex' | ||
- '**/*.fc' | ||
- '**/*.javascript' | ||
- '**/*.properties' | ||
- '**/*.thrift' | ||
- '**/*.sh' | ||
- '**/*.bat' | ||
- '**/*.md' | ||
- '**/*.svg' | ||
- '**/*.png' | ||
- '**/*.json' | ||
- '**/*.conf' | ||
- '**/*.ftl' | ||
- '**/*.tpl' | ||
- '**/*.factories' | ||
- '**/*.handlers' | ||
- '**/*.schemas' | ||
- '**/*.nojekyll' | ||
- '.git/' | ||
- '.github/**' | ||
- '**/.gitignore' | ||
- '**/.helmignore' | ||
- '.repository/' | ||
- 'compiler/**' | ||
- '.gitmodules' | ||
- '**/.run/**' | ||
- '**/.images/**' | ||
- '**/proto/**' | ||
- 'dist' | ||
- 'licenses' | ||
- '**/*.md' | ||
- 'LICENSE' | ||
- 'NOTICE' | ||
- 'go.mod' | ||
- 'go.sum' | ||
- '**/*.yml' | ||
- '**/*.yaml' | ||
- '**/*.css' | ||
- '**/*.js' | ||
- '**/Dockerfile' | ||
- '**/*.xml' | ||
- '**/*.html' | ||
- '**/*.pem' | ||
- '**/protobuf.mk' | ||
- '**/*.java' | ||
- 'apisix/mysql5.7-compose/mysql/my.cnf' | ||
- 'build/Makefile' | ||
- 'tls/x509/openssl.cnf' | ||
|
||
comment: on-failure | ||
|
||
license-location-threshold: 130 |
17 changes: 17 additions & 0 deletions
17
generic/default/java-server/src/main/java/org/apache/dubbo/samples/UserProviderTriple.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,78 @@ | ||
# Helloworld for dubbo-go Triple | ||
# Helloworld for dubbo-go | ||
|
||
This is **Triple** helloworld example to help you finish a basic RPC invocation done quickly. | ||
This example demonstrates the basic usage of dubbo-go as an RPC framework. Check [Quick Start][] on our official website for detailed explanation. | ||
|
||
## Prerequisites | ||
## Contents | ||
|
||
### install protocol buffer compiler, protoc, [version3](https://protobuf.dev/programming-guides/proto3/) | ||
- server/main.go - is the main definition of the service, handler and rpc server | ||
- client/main.go - is the rpc client | ||
- proto - contains the protobuf definition of the API | ||
|
||
Please refer to [**Protocol Buffer Compiler Installation**](https://grpc.io/docs/protoc-installation/) and [**Download Protocol Buffers**](https://protobuf.dev/downloads/). | ||
After installation, please run ```protoc --verion``` to ensure that the version of protoc is 3+. | ||
## How to run | ||
|
||
### install protoc-gen-go | ||
[//]: # (### Prerequisites) | ||
|
||
```shell | ||
# install the version of your choice of protoc-gen-go. here use the latest version as example | ||
go install google.golang.org/protobuf/cmd/[email protected] | ||
``` | ||
[//]: # () | ||
[//]: # (1. Install `protoc [version3][]`) | ||
|
||
### install protoc-gen-triple | ||
[//]: # () | ||
[//]: # ( Please refer to [Protocol Buffer Compiler Installation][].) | ||
|
||
```shell | ||
# install the latest version of protoc-gen-triple | ||
git clone https://github.com/apache/dubbo-go.git && cd ./dubbo-go | ||
git checkout feature-triple | ||
go mod tidy | ||
cd ./protocol/triple/triple-tool/protoc-gen-triple | ||
go install . | ||
``` | ||
[//]: # () | ||
[//]: # (2. Install `protoc-gen-go` and `protoc-gen-triple` ) | ||
|
||
## Generate Triple stub code | ||
[//]: # () | ||
[//]: # ( ```shell) | ||
|
||
```shell | ||
mkdir ~/triple_helloworld && cd ~/triple_helloworld | ||
go mod init triple_helloworld | ||
mkdir proto && cd ./proto | ||
[//]: # ( # install the version of your choice of protoc-gen-go. here use the latest version as example) | ||
|
||
# replace this with your own proto IDL file | ||
cat > greet.proto << EOF | ||
syntax = "proto3"; | ||
[//]: # ( go install google.golang.org/protobuf/cmd/[email protected]) | ||
|
||
package greet; | ||
[//]: # ( ) | ||
[//]: # ( # install the latest version of protoc-gen-triple) | ||
|
||
option go_package = "triple_helloworld/proto;greet"; | ||
[//]: # ( git clone https://github.com/apache/dubbo-go.git && cd ./dubbo-go) | ||
|
||
message GreetRequest { | ||
string name = 1; | ||
} | ||
[//]: # ( git checkout feature-triple) | ||
|
||
message GreetResponse { | ||
string greeting = 1; | ||
} | ||
[//]: # ( go mod tidy) | ||
|
||
service GreetService { | ||
rpc Greet(GreetRequest) returns (GreetResponse) {} | ||
} | ||
[//]: # ( cd ./protocol/triple/triple-tool/protoc-gen-triple) | ||
|
||
EOF | ||
[//]: # ( go install .) | ||
|
||
# generate related stub code with protoc-gen-go and protoc-gen-triple | ||
protoc --go_out=. --go_opt=paths=source_relative --triple_out=. --triple_opt=paths=source_relative ./greet.proto | ||
``` | ||
[//]: # ( ```) | ||
|
||
## Finish client and server code | ||
[//]: # () | ||
[//]: # (### Generate stub code) | ||
|
||
### client | ||
[//]: # () | ||
[//]: # (```shell) | ||
|
||
Finish **client.go**. For specific code, please refer to [**this**](https://github.com/apache/dubbo-go-samples/blob/new-triple-samples/helloworld/client.go) | ||
[//]: # (# generate related stub code with protoc-gen-go and protoc-gen-triple) | ||
|
||
### server | ||
[//]: # (protoc --go_out=. --go_opt=paths=source_relative --triple_out=. --triple_opt=paths=source_relative ./greet.proto) | ||
|
||
Implement **GreetService** Interface and finish **server.go**. For specific code, please refer to [**this**](https://github.com/apache/dubbo-go-samples/blob/new-triple-samples/helloworld/server.go). | ||
[//]: # (```) | ||
|
||
## Build and run | ||
### Run server | ||
```shell | ||
go run ./server/main.go | ||
``` | ||
|
||
test server work as expected: | ||
```shell | ||
cd ~/triple_helloworld | ||
go build -o server ./server.go | ||
./server | ||
curl \ | ||
--header "Content-Type: application/json" \ | ||
--data '{"name": "Dubbo"}' \ | ||
http://localhost:20000/greet.GreetService/Greet | ||
``` | ||
|
||
### Run client | ||
```shell | ||
cd ~/triple_helloworld | ||
go build -o client ./client.go | ||
./client | ||
``` | ||
go run ./client/main.go | ||
``` | ||
|
||
[Quick Start]: https://dubbo-next.staged.apache.org/zh-cn/overview/mannual/golang-sdk/quickstart/ | ||
[version3]: https://protobuf.dev/programming-guides/proto3/ | ||
[Protocol Buffer Compiler Installation]: https://dubbo-next.staged.apache.org/zh-cn/overview/reference/protoc-installation/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
17 changes: 17 additions & 0 deletions
17
rpc/dubbo/java-client/src/main/java/org/apache/dubbo/sample/WrapperArrayClassProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.