Skip to content

Commit

Permalink
Merge pull request #642 from chickenlj/new-triple-samples-helloworld
Browse files Browse the repository at this point in the history
Polish helloworld
  • Loading branch information
chickenlj authored Oct 31, 2023
2 parents 0ecee7b + 9465498 commit 61a49b7
Show file tree
Hide file tree
Showing 17 changed files with 280 additions and 148 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ jobs:
with:
args: --timeout 10m --verbose

- name: License
run: make -f build/Makefile license
- name: Check License Header
uses: apache/skywalking-eyes/header@e1a02359b239bd28de3f6d35fdc870250fa513d5

- name: Integration Test
run: |
Expand Down
88 changes: 88 additions & 0 deletions .licenserc.yaml
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
Original file line number Diff line number Diff line change
@@ -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.
*/

package org.apache.dubbo.samples;

import java.util.ArrayList;
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
module github.com/apache/dubbo-go-samples

require (
dubbo.apache.org/dubbo-go/v3 v3.1.1-0.20231026074600-9d62f726adba
dubbo.apache.org/dubbo-go/v3 v3.1.1-0.20231027101150-15c43b823e74
github.com/SkyAPM/go2sky v1.5.0
github.com/SkyAPM/go2sky-plugins/dubbo-go v0.0.0-20220718123631-cb8f743b16cf
github.com/apache/dubbo-go-hessian2 v1.12.2
github.com/dubbogo/gost v1.14.0
github.com/dubbogo/grpc-go v1.42.10
github.com/dubbogo/tools v1.0.9 // indirect
github.com/dubbogo/triple v1.2.2-rc3
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.5.3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,8 @@ dubbo.apache.org/dubbo-go/v3 v3.0.2-0.20220508105316-b27ec53b7bab/go.mod h1:Ytn9
dubbo.apache.org/dubbo-go/v3 v3.0.2/go.mod h1:bODgByAf72kzG/5YIfZIODXx81pY3gaAdIQ8B4mN/Yk=
dubbo.apache.org/dubbo-go/v3 v3.1.1-0.20231026074600-9d62f726adba h1:lbfKnvjIC8Nz1wlVQ8jX5IDv63CXny1rz34v+fkjSao=
dubbo.apache.org/dubbo-go/v3 v3.1.1-0.20231026074600-9d62f726adba/go.mod h1:7Gl3GACKWMz5Xz2lpgoKG7qDXerxhHnxoMJRmrYkw18=
dubbo.apache.org/dubbo-go/v3 v3.1.1-0.20231027101150-15c43b823e74 h1:2W2oqz0BQbNULmvtokHbx5j86sDpCjd9OAi7wSpj9zA=
dubbo.apache.org/dubbo-go/v3 v3.1.1-0.20231027101150-15c43b823e74/go.mod h1:hGmY1esW7CV++/TKENtPCYnwZ4G55CeXkpDqLsLVOpU=
gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8=
git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc=
github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI=
Expand Down
105 changes: 49 additions & 56 deletions helloworld/README.md
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/
85 changes: 0 additions & 85 deletions helloworld/README_zh.md

This file was deleted.

2 changes: 1 addition & 1 deletion helloworld/client.go → helloworld/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

func main() {
cli, err := client.NewClient(
client.WithURL("127.0.0.1:20000"),
client.WithURL("tri://127.0.0.1:20000"),
)
if err != nil {
panic(err)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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.
*/

package org.apache.dubbo.sample;

public interface WrapperArrayClassProvider {
Expand Down
Loading

0 comments on commit 61a49b7

Please sign in to comment.