Skip to content

Commit

Permalink
Fix: add zh and en triple readme and some features (apache#265)
Browse files Browse the repository at this point in the history
* fix: add triple readme

* fix: change config api

* fix: liscence

* remote tabs in README.md
  • Loading branch information
LaurenceLiZhixin authored Oct 2, 2021
1 parent 69d34c3 commit 0045a96
Show file tree
Hide file tree
Showing 89 changed files with 716 additions and 384 deletions.
Binary file added .images/samples-rpc-triple-client.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .images/samples-rpc-triple-server.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions .run/direct-client.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="direct-client" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="direct">
<module name="dubbo-go-samples" />
<working_directory value="$PROJECT_DIR$" />
<envs>
<env name="DUBBO_GO_CONFIG_PATH" value="$PROJECT_DIR$/direct/go-client/conf/dubbogo.yml" />
</envs>
<kind value="PACKAGE" />
<package value="github.com/apache/dubbo-go-samples/direct/go-client/cmd" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$/helloworld/go-client/cmd/client.go" />
<method v="2" />
</configuration>
</component>
14 changes: 14 additions & 0 deletions .run/direct-server.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="direct-server" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="direct">
<module name="dubbo-go-samples" />
<working_directory value="$PROJECT_DIR$" />
<envs>
<env name="DUBBO_GO_CONFIG_PATH" value="$PROJECT_DIR$/direct/go-server/conf/dubbogo.yml" />
</envs>
<kind value="PACKAGE" />
<package value="github.com/apache/dubbo-go-samples/direct/go-server/cmd" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$/helloworld/go-client/cmd/client.go" />
<method v="2" />
</configuration>
</component>
2 changes: 1 addition & 1 deletion .run/dubbo-go-server.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<module name="dubbo-go-samples" />
<working_directory value="$PROJECT_DIR$" />
<envs>
<env name="DUBBO_GO_CONFIG_PATH" value="$PROJECT_DIR$/rpc/dubbo/go-client/conf/dubbogo.yml" />
<env name="DUBBO_GO_CONFIG_PATH" value="$PROJECT_DIR$/rpc/dubbo/go-server/conf/dubbogo.yml" />
</envs>
<kind value="PACKAGE" />
<package value="github.com/apache/dubbo-go-samples/rpc/dubbo/go-server/cmd" />
Expand Down
14 changes: 14 additions & 0 deletions .run/grpc-go-client.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="grpc-go-client" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="rpc/grpc">
<module name="dubbo-go-samples" />
<working_directory value="$PROJECT_DIR$" />
<envs>
<env name="DUBBO_GO_CONFIG_PATH" value="$PROJECT_DIR$/rpc/grpc/go-client/conf/dubbogo.yml" />
</envs>
<kind value="PACKAGE" />
<package value="github.com/apache/dubbo-go-samples/rpc/grpc/go-client/cmd" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$/rpc/dubbo/go-client/cmd/client.go" />
<method v="2" />
</configuration>
</component>
14 changes: 14 additions & 0 deletions .run/grpc-go-server.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="grpc-go-server" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="rpc/grpc">
<module name="dubbo-go-samples" />
<working_directory value="$PROJECT_DIR$" />
<envs>
<env name="DUBBO_GO_CONFIG_PATH" value="$PROJECT_DIR$/rpc/grpc/go-server/conf/dubbogo.yml" />
</envs>
<kind value="PACKAGE" />
<package value="github.com/apache/dubbo-go-samples/rpc/grpc/go-server/cmd" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$/rpc/dubbo/go-client/cmd/client.go" />
<method v="2" />
</configuration>
</component>
14 changes: 14 additions & 0 deletions .run/triple-codec-extension-client.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="triple-codec-extension-client" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="rpc/triple">
<module name="dubbo-go-samples" />
<working_directory value="$PROJECT_DIR$" />
<envs>
<env name="DUBBO_GO_CONFIG_PATH" value="$PROJECT_DIR$/rpc/triple/codec-extension/go-client/conf/dubbogo.yml" />
</envs>
<kind value="PACKAGE" />
<package value="github.com/apache/dubbo-go-samples/rpc/triple/codec-extension/go-client/cmd" />
<directory value="github.com/apache/dubbo-go-samples/general/dubbo3/api/dubbogo-grpc/server/dubbogo-server/cmd" />
<filePath value="$PROJECT_DIR$" />
<method v="2" />
</configuration>
</component>
14 changes: 14 additions & 0 deletions .run/triple-codec-extension-server.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="triple-codec-extension-server" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="rpc/triple">
<module name="dubbo-go-samples" />
<working_directory value="$PROJECT_DIR$" />
<envs>
<env name="DUBBO_GO_CONFIG_PATH" value="$PROJECT_DIR$/rpc/triple/codec-extension/go-server/conf/dubbogo.yml" />
</envs>
<kind value="PACKAGE" />
<package value="github.com/apache/dubbo-go-samples/rpc/triple/codec-extension/go-server/cmd" />
<directory value="github.com/apache/dubbo-go-samples/general/dubbo3/api/dubbogo-grpc/server/dubbogo-server/cmd" />
<filePath value="$PROJECT_DIR$" />
<method v="2" />
</configuration>
</component>
8 changes: 4 additions & 4 deletions .run/triple/triple-msgpack-client.run.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="triple-msgpack-client" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="triple">
<configuration default="false" name="triple-msgpack-client" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="rpc/triple">
<module name="dubbo-go-samples" />
<working_directory value="$PROJECT_DIR$" />
<envs>
<env name="CONF_CONSUMER_FILE_PATH" value="$PROJECT_DIR$/rpc/dubbo3/msgpack/go-client/conf/dubbogo.yml" />
<env name="DUBBO_GO_CONFIG_PATH" value="$PROJECT_DIR$/rpc/triple/msgpack/go-client/conf/dubbogo.yml" />
</envs>
<kind value="PACKAGE" />
<filePath value="$PROJECT_DIR$/rpc/dubbo3/msgpack/go-client/cmd/client.go" />
<package value="github.com/apache/dubbo-go-samples/rpc/dubbo3/msgpack/go-client/cmd" />
<package value="github.com/apache/dubbo-go-samples/rpc/triple/msgpack/go-client/cmd" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$/rpc/dubbo3/msgpack/go-client/cmd/client.go" />
<method v="2" />
</configuration>
</component>
8 changes: 4 additions & 4 deletions .run/triple/triple-msgpack-server.run.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="triple-msgpack-server" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="triple">
<configuration default="false" name="triple-msgpack-server" type="GoApplicationRunConfiguration" factoryName="Go Application" folderName="rpc/triple">
<module name="dubbo-go-samples" />
<working_directory value="$PROJECT_DIR$" />
<envs>
<env name="CONF_PROVIDER_FILE_PATH" value="$PROJECT_DIR$/rpc/dubbo3/msgpack/go-server/conf/dubbogo.yml" />
<env name="DUBBO_GO_CONFIG_PATH" value="$PROJECT_DIR$/rpc/triple/msgpack/go-server/conf/dubbogo.yml" />
</envs>
<kind value="PACKAGE" />
<filePath value="$PROJECT_DIR$/rpc/dubbo3/msgpack/go-server/cmd/server.go" />
<package value="github.com/apache/dubbo-go-samples/rpc/dubbo3/msgpack/go-server/cmd" />
<package value="github.com/apache/dubbo-go-samples/rpc/triple/msgpack/go-server/cmd" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$/rpc/dubbo3/msgpack/go-server/cmd/server.go" />
<method v="2" />
</configuration>
</component>
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
* rpc: dubbo directory display dubbo protocol communication
* generic: A generic invocation example
* helloworld: A 101 example
* multi_registry: A multi-registry example
* registry: uses of different registres, including kubernetes, nacos, etcd and service-discovery
* router: router examples, including condition and tag
* seata: A seata example
* shop: Shop sample
Expand Down
24 changes: 11 additions & 13 deletions config-api/configcenter/nacos/go-client/cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dubbo:
timeout: 3s
address: 127.0.0.1:2181
consumer:
registry:
registries:
- demoZK
references:
GreeterClientImpl:
Expand All @@ -51,9 +51,10 @@ var grpcGreeterImpl = new(api.GreeterClientImpl)

// There is no need to export DUBBO_GO_CONFIG_PATH, as you are using config api to set config
func main() {
dynamicConfig, err := config.NewConfigCenterConfig(
config.WithConfigCenterProtocol("nacos"),
config.WithConfigCenterAddress("127.0.0.1:8848")).GetDynamicConfiguration()
dynamicConfig, err := config.NewConfigCenterConfigBuilder().
SetProtocol("nacos").
SetAddress("127.0.0.1:8848").
Build().GetDynamicConfiguration()
if err != nil {
panic(err)
}
Expand All @@ -63,15 +64,12 @@ func main() {

config.SetConsumerService(grpcGreeterImpl)

centerConfig := config.NewConfigCenterConfig(
config.WithConfigCenterProtocol("nacos"),
config.WithConfigCenterAddress("localhost:8848"),
config.WithConfigCenterDataID("dubbo-go-samples-configcenter-nacos-client"),
)

rootConfig := config.NewRootConfig(
config.WithRootCenterConfig(centerConfig),
)
rootConfig := config.NewRootConfigBuilder().
SetConfigCenter(config.NewConfigCenterConfigBuilder().
SetProtocol("nacos").SetAddress("127.0.0.1:8848").
SetDataID("dubbo-go-samples-configcenter-nacos-client").
Build()).
Build()

if err := rootConfig.Init(); err != nil {
panic(err)
Expand Down
25 changes: 13 additions & 12 deletions config-api/configcenter/nacos/go-server/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dubbo:
name: tri
port: 20000
provider:
registry:
registries:
- demoZK
services:
GreeterProvider:
Expand All @@ -62,27 +62,28 @@ func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*

// There is no need to export DUBBO_GO_CONFIG_PATH, as you are using config api to set config
func main() {
dynamicConfig, err := config.NewConfigCenterConfig(
config.WithConfigCenterProtocol("nacos"),
config.WithConfigCenterAddress("127.0.0.1:8848")).GetDynamicConfiguration()
dynamicConfig, err := config.NewConfigCenterConfigBuilder().
SetProtocol("nacos").
SetAddress("127.0.0.1:8848").
Build().GetDynamicConfiguration()

if err != nil {
panic(err)
}

if err := dynamicConfig.PublishConfig("dubbo-go-samples-configcenter-nacos-server", "dubbo", configCenterNacosServerConfig); err != nil {
panic(err)
}
time.Sleep(time.Second * 10)

config.SetProviderService(&GreeterProvider{})
centerConfig := config.NewConfigCenterConfig(
config.WithConfigCenterProtocol("nacos"),
config.WithConfigCenterAddress("127.0.0.1:8848"),
config.WithConfigCenterDataID("dubbo-go-samples-configcenter-nacos-server"),
)

rootConfig := config.NewRootConfig(
config.WithRootCenterConfig(centerConfig),
)
rootConfig := config.NewRootConfigBuilder().
SetConfigCenter(config.NewConfigCenterConfigBuilder().
SetProtocol("nacos").SetAddress("127.0.0.1:8848").
SetDataID("dubbo-go-samples-configcenter-nacos-server").
Build()).
Build()

if err := rootConfig.Init(); err != nil {
panic(err)
Expand Down
29 changes: 12 additions & 17 deletions config-api/configcenter/zookeeper/go-client/cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dubbo:
timeout: 3s
address: 127.0.0.1:8848
consumer:
registry:
registries:
- demoZK
references:
GreeterClientImpl:
Expand All @@ -51,28 +51,23 @@ var grpcGreeterImpl = new(api.GreeterClientImpl)

// There is no need to export DUBBO_GO_CONFIG_PATH, as you are using config api to set config
func main() {
dynamicConfig, err := config.NewConfigCenterConfig(
config.WithConfigCenterProtocol("zookeeper"),
config.WithConfigCenterAddress("127.0.0.1:2181")).GetDynamicConfiguration()
if err != nil {
panic(err)
}
dynamicConfig, err := config.NewConfigCenterConfigBuilder().
SetProtocol("zookeeper").
SetAddress("127.0.0.1:2181").
Build().GetDynamicConfiguration()

if err := dynamicConfig.PublishConfig("dubbo-go-samples-configcenter-zookeeper-client", "dubbogo", configCenterZKClientConfig); err != nil {
panic(err)
}

config.SetConsumerService(grpcGreeterImpl)

centerConfig := config.NewConfigCenterConfig(
config.WithConfigCenterProtocol("zookeeper"),
config.WithConfigCenterAddress("localhost:2181"),
config.WithConfigCenterDataID("dubbo-go-samples-configcenter-zookeeper-client"),
config.WithConfigCenterGroup("dubbogo"),
)

rootConfig := config.NewRootConfig(
config.WithRootCenterConfig(centerConfig),
)
rootConfig := config.NewRootConfigBuilder().
SetConfigCenter(config.NewConfigCenterConfigBuilder().
SetProtocol("nacos").SetAddress("127.0.0.1:2182").
SetDataID("dubbo-go-samples-configcenter-zookeeper-client").
Build()).
Build()

if err := rootConfig.Init(); err != nil {
panic(err)
Expand Down
25 changes: 12 additions & 13 deletions config-api/configcenter/zookeeper/go-server/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dubbo:
name: tri
port: 20000
provider:
registry:
registries:
- demoZK
services:
GreeterProvider:
Expand All @@ -62,9 +62,10 @@ func (s *GreeterProvider) SayHello(ctx context.Context, in *api.HelloRequest) (*

// There is no need to export DUBBO_GO_CONFIG_PATH, as you are using config api to set config
func main() {
dynamicConfig, err := config.NewConfigCenterConfig(
config.WithConfigCenterProtocol("zookeeper"),
config.WithConfigCenterAddress("127.0.0.1:2181")).GetDynamicConfiguration()
dynamicConfig, err := config.NewConfigCenterConfigBuilder().
SetProtocol("zookeeper").
SetAddress("127.0.0.1:2181").
Build().GetDynamicConfiguration()
if err != nil {
panic(err)
}
Expand All @@ -75,16 +76,14 @@ func main() {
time.Sleep(time.Second * 10)

config.SetProviderService(&GreeterProvider{})
centerConfig := config.NewConfigCenterConfig(
config.WithConfigCenterProtocol("zookeeper"),
config.WithConfigCenterAddress("127.0.0.1:2181"),
config.WithConfigCenterDataID("dubbo-go-samples-configcenter-zookeeper-server"),
config.WithConfigCenterGroup("dubbogo"),
)

rootConfig := config.NewRootConfig(
config.WithRootCenterConfig(centerConfig),
)
rootConfig := config.NewRootConfigBuilder().
SetConfigCenter(config.NewConfigCenterConfigBuilder().
SetProtocol("zookeeper").SetAddress("127.0.0.1:2181").
SetDataID("dubbo-go-samples-configcenter-zookeeper-server").
SetGroup("dubbogo").
Build()).
Build()

if err := rootConfig.Init(); err != nil {
panic(err)
Expand Down
26 changes: 10 additions & 16 deletions config-api/rpc/triple/go-client/cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,16 @@ var tripleGreeterImpl = new(api.GreeterClientImpl)
func main() {
config.SetConsumerService(tripleGreeterImpl)

referenceConfig := config.NewReferenceConfig(
config.WithReferenceInterface("com.apache.dubbo.sample.basic.IGreeter"),
config.WithReferenceProtocolName("tri"),
config.WithReferenceRegistry("zkRegistryKey"),
)

consumerConfig := config.NewConsumerConfig(
config.WithConsumerReferenceConfig("GreeterClientImpl", referenceConfig),
)

registryConfig := config.NewRegistryConfigWithProtocolDefaultPort("zookeeper")

rootConfig := config.NewRootConfig(
config.WithRootRegistryConfig("zkRegistryKey", registryConfig),
config.WithRootConsumerConfig(consumerConfig),
)
rootConfig := config.NewRootConfigBuilder().
SetConsumer(config.NewConsumerConfigBuilder().
SetRegistries("zkRegistryKey").
AddReference("GreeterClientImpl", config.NewReferenceConfigBuilder().
SetInterface("com.apache.dubbo.sample.basic.IGreeter").
SetProtocol("tri").
Build()).
Build()).
AddRegistry("zkRegistryKey", config.NewRegistryConfigWithProtocolDefaultPort("zookeeper")).
Build()

if err := rootConfig.Init(); err != nil {
panic(err)
Expand Down
Loading

0 comments on commit 0045a96

Please sign in to comment.