This document demonstrates how to use a yaml
configuration file in the framework for microservice development, which is an alternative development model compared to API
. You can fully develop using a yml
configuration file or put some global configurations in the configuration file, while defining services only in the API.
In this mode, you must specify the configuration file path through DUBBO_GO_CONFIG_PATH
:
You can view the complete example source code here.
Define services using IDL ./proto/greet.proto
with the triple protocol.
The yaml
file defined by the client:
Call dubbo.Load()
to read and load the file.
The yaml
file defined by the server:
Call dubbo.Load()
to read and load the file.
Source file path: dubbo-go-sample/context/proto/greet.proto
In the server, define GreetTripleServer:
Implement the GreetServiceHandler interface and register it via greet.SetProviderService(&GreetTripleServer{})
, also load the configuration file with dubbo.Load()
.
Source file path: dubbo-go-sample/config_yaml/go-server/cmd/main.go
In the client, definegreet.GreetServiceImpl
instance and register with greet.SetConsumerService(svc)
; load the configuration file with dubbo.Load()
.
Source file path: dubbo-go-sample/config_yaml/go-client/cmd/main.go
Start the server first, then start the client, and you can observe the client printing ConfigTest successfully
configuration loading and calling success.
If you want to specify multiple filters, you can separate them with ‘,’.
Consumer Side
Provider Side