Skip to content

Commit 5ea6df5

Browse files
authored
Fix: fix echo example (apache#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.
1 parent cfa1214 commit 5ea6df5

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

config/src/config.rs

+16-3
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ impl RootConfig {
106106
.serializer("json".to_string())
107107
.version("1.0.0".to_string())
108108
.protocol_names("triple".to_string())
109-
.name("grpc.examples.echo.Echo".to_string());
109+
// Currently, the hello_echo.rs doesn't support the url which like
110+
// `{protocol}/{service config name}/{service name}(e.g. triple://0.0.0.0:8888/{service config name}/grpc.examples.echo.Echo).
111+
// So we comment this line.
112+
// .name("grpc.examples.echo.Echo".to_strdding())
113+
.registry("zookeeper".to_string());
110114

111115
let triple_config = ProtocolConfig::default()
112116
.name("triple".to_string())
@@ -122,8 +126,9 @@ impl RootConfig {
122126
.group("test".to_string())
123127
.serializer("json".to_string())
124128
.version("1.0.0".to_string())
125-
.name("helloworld.Greeter".to_string())
126-
.protocol_names("triple".to_string()),
129+
// .name("helloworld.Greeter".to_string())
130+
.protocol_names("triple".to_string())
131+
.registry("zookeeper".to_string()),
127132
);
128133
self.protocols.insert(
129134
"triple".to_string(),
@@ -135,6 +140,14 @@ impl RootConfig {
135140

136141
provider.services = self.service.clone();
137142
self.provider = provider.clone();
143+
144+
let mut registries = HashMap::new();
145+
registries.insert(
146+
"zookeeper".to_string(),
147+
"zookeeper://localhost:2181".to_string(),
148+
);
149+
self.registries = registries;
150+
138151
println!("provider config: {:?}", provider);
139152
// 通过环境变量读取某个文件。加在到内存中
140153
self.data.insert(

config/src/service.rs

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ impl ServiceConfig {
5757
Self { serializer, ..self }
5858
}
5959

60+
pub fn registry(self, registry: String) -> Self {
61+
Self { registry, ..self }
62+
}
63+
6064
pub fn add_protocol_configs(mut self, protocol_config: ProtocolConfig) -> Self {
6165
self.protocol_configs
6266
.insert(protocol_config.name.clone(), protocol_config);

dubbo/src/framework.rs

+4
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ impl Dubbo {
9292
.and_modify(|urls| urls.push(protocol_url.clone()))
9393
.or_insert(vec![protocol_url]);
9494

95+
tracing::debug!(
96+
"service name: {service_name}, service_config: {:?}",
97+
service_config
98+
);
9599
let registry = &service_config.registry;
96100
let reg_url = self
97101
.registries

0 commit comments

Comments
 (0)