@@ -21,6 +21,7 @@ use std::pin::Pin;
21
21
use futures:: future;
22
22
use futures:: Future ;
23
23
24
+ use crate :: common:: consts;
24
25
use crate :: common:: url:: Url ;
25
26
use crate :: protocol:: { BoxExporter , Protocol } ;
26
27
use crate :: registry:: protocol:: RegistryProtocol ;
@@ -32,6 +33,7 @@ use dubbo_config::{get_global_config, RootConfig};
32
33
pub struct Dubbo {
33
34
protocols : HashMap < String , Vec < Url > > ,
34
35
registries : HashMap < String , Url > ,
36
+ services : HashMap < String , Vec < Url > > , // protocol: Url; registry: Url
35
37
config : Option < RootConfig > ,
36
38
}
37
39
@@ -41,6 +43,7 @@ impl Dubbo {
41
43
Self {
42
44
protocols : HashMap :: new ( ) ,
43
45
registries : HashMap :: new ( ) ,
46
+ services : HashMap :: new ( ) ,
44
47
config : None ,
45
48
}
46
49
}
@@ -63,7 +66,7 @@ impl Dubbo {
63
66
. insert ( name. to_string ( ) , Url :: from_url ( url) . unwrap ( ) ) ;
64
67
}
65
68
66
- for ( _, c) in conf. service . iter ( ) {
69
+ for ( _, c) in conf. provider . services . iter ( ) {
67
70
let u = if c. protocol_configs . is_empty ( ) {
68
71
let protocol = match conf. protocols . get ( & c. protocol ) {
69
72
Some ( v) => v. to_owned ( ) ,
@@ -91,6 +94,26 @@ impl Dubbo {
91
94
}
92
95
93
96
let u = u. unwrap ( ) ;
97
+ if self . services . get ( consts:: PROTOCOL ) . is_some ( ) {
98
+ self . services
99
+ . get_mut ( consts:: PROTOCOL )
100
+ . unwrap ( )
101
+ . push ( u. clone ( ) ) ;
102
+ } else {
103
+ self . services
104
+ . insert ( consts:: PROTOCOL . to_string ( ) , vec ! [ u. clone( ) ] ) ;
105
+ }
106
+
107
+ if self . services . get ( consts:: REGISTRY ) . is_some ( ) {
108
+ self . services
109
+ . get_mut ( consts:: REGISTRY )
110
+ . unwrap ( )
111
+ . push ( u. clone ( ) ) ;
112
+ } else {
113
+ self . services
114
+ . insert ( consts:: REGISTRY . to_string ( ) , vec ! [ u. clone( ) ] ) ;
115
+ }
116
+
94
117
if self . protocols . get ( & c. protocol ) . is_some ( ) {
95
118
self . protocols . get_mut ( & c. protocol ) . unwrap ( ) . push ( u) ;
96
119
} else {
0 commit comments