You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by ya...@apache.org on 2022/11/17 15:18:02 UTC
[dubbo-rust] branch main updated: Fix: fix echo example (#77)
This is an automated email from the ASF dual-hosted git repository.
yangyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/dubbo-rust.git
The following commit(s) were added to refs/heads/main by this push:
new 5ea6df5 Fix: fix echo example (#77)
5ea6df5 is described below
commit 5ea6df59ae70ee40bd8dbbd854132d50a65eab17
Author: xuankun zheng <zh...@163.com>
AuthorDate: Thu Nov 17 23:17:56 2022 +0800
Fix: fix echo example (#77)
* Rft: default config init and Dubbo::init
* Fix: make the GLOBAL_ROOT_CONFIG initialize lazily
* Fix: fix the echo example.
* Fix: fix the echo example.
---
config/src/config.rs | 19 ++++++++++++++++---
config/src/service.rs | 4 ++++
dubbo/src/framework.rs | 4 ++++
3 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/config/src/config.rs b/config/src/config.rs
index 36aa047..a17e31a 100644
--- a/config/src/config.rs
+++ b/config/src/config.rs
@@ -106,7 +106,11 @@ impl RootConfig {
.serializer("json".to_string())
.version("1.0.0".to_string())
.protocol_names("triple".to_string())
- .name("grpc.examples.echo.Echo".to_string());
+ // Currently, the hello_echo.rs doesn't support the url which like
+ // `{protocol}/{service config name}/{service name}(e.g. triple://0.0.0.0:8888/{service config name}/grpc.examples.echo.Echo).
+ // So we comment this line.
+ // .name("grpc.examples.echo.Echo".to_strdding())
+ .registry("zookeeper".to_string());
let triple_config = ProtocolConfig::default()
.name("triple".to_string())
@@ -122,8 +126,9 @@ impl RootConfig {
.group("test".to_string())
.serializer("json".to_string())
.version("1.0.0".to_string())
- .name("helloworld.Greeter".to_string())
- .protocol_names("triple".to_string()),
+ // .name("helloworld.Greeter".to_string())
+ .protocol_names("triple".to_string())
+ .registry("zookeeper".to_string()),
);
self.protocols.insert(
"triple".to_string(),
@@ -135,6 +140,14 @@ impl RootConfig {
provider.services = self.service.clone();
self.provider = provider.clone();
+
+ let mut registries = HashMap::new();
+ registries.insert(
+ "zookeeper".to_string(),
+ "zookeeper://localhost:2181".to_string(),
+ );
+ self.registries = registries;
+
println!("provider config: {:?}", provider);
// 通过环境变量读取某个文件。加在到内存中
self.data.insert(
diff --git a/config/src/service.rs b/config/src/service.rs
index 0020b4c..a876c0a 100644
--- a/config/src/service.rs
+++ b/config/src/service.rs
@@ -57,6 +57,10 @@ impl ServiceConfig {
Self { serializer, ..self }
}
+ pub fn registry(self, registry: String) -> Self {
+ Self { registry, ..self }
+ }
+
pub fn add_protocol_configs(mut self, protocol_config: ProtocolConfig) -> Self {
self.protocol_configs
.insert(protocol_config.name.clone(), protocol_config);
diff --git a/dubbo/src/framework.rs b/dubbo/src/framework.rs
index 4c08604..da21ab8 100644
--- a/dubbo/src/framework.rs
+++ b/dubbo/src/framework.rs
@@ -92,6 +92,10 @@ impl Dubbo {
.and_modify(|urls| urls.push(protocol_url.clone()))
.or_insert(vec![protocol_url]);
+ tracing::debug!(
+ "service name: {service_name}, service_config: {:?}",
+ service_config
+ );
let registry = &service_config.registry;
let reg_url = self
.registries