@@ -21,6 +21,7 @@ use lazy_static::lazy_static;
21
21
use serde:: { Deserialize , Serialize } ;
22
22
23
23
use super :: protocol:: ProtocolConfig ;
24
+ use super :: provider:: ProviderConfig ;
24
25
use super :: service:: ServiceConfig ;
25
26
26
27
pub const DUBBO_CONFIG_PATH : & str = "./dubbo.yaml" ;
@@ -35,10 +36,14 @@ lazy_static! {
35
36
#[ derive( Debug , Default , Serialize , Deserialize , Clone ) ]
36
37
pub struct RootConfig {
37
38
pub name : String ,
39
+
40
+ #[ serde( skip_serializing, skip_deserializing) ]
38
41
pub service : HashMap < String , ServiceConfig > ,
39
42
pub protocols : HashMap < String , ProtocolConfig > ,
40
43
pub registries : HashMap < String , String > ,
41
44
45
+ pub provider : ProviderConfig ,
46
+
42
47
#[ serde( skip_serializing, skip_deserializing) ]
43
48
pub data : HashMap < String , String > ,
44
49
}
@@ -65,6 +70,7 @@ impl RootConfig {
65
70
service : HashMap :: new ( ) ,
66
71
protocols : HashMap :: new ( ) ,
67
72
registries : HashMap :: new ( ) ,
73
+ provider : ProviderConfig :: new ( ) ,
68
74
data : HashMap :: new ( ) ,
69
75
}
70
76
}
@@ -96,6 +102,10 @@ impl RootConfig {
96
102
}
97
103
98
104
pub fn test_config ( & mut self ) {
105
+ let mut provider = ProviderConfig :: new ( ) ;
106
+ provider. protocol_ids = vec ! [ "triple" . to_string( ) ] ;
107
+ provider. registry_ids = vec ! [ ] ;
108
+
99
109
let service_config = ServiceConfig :: default ( )
100
110
. group ( "test" . to_string ( ) )
101
111
. serializer ( "json" . to_string ( ) )
@@ -127,6 +137,10 @@ impl RootConfig {
127
137
. ip ( "0.0.0.0" . to_string ( ) )
128
138
. port ( "8889" . to_string ( ) ) ,
129
139
) ;
140
+
141
+ provider. services = self . service . clone ( ) ;
142
+ self . provider = provider. clone ( ) ;
143
+ println ! ( "provider config: {:?}" , provider) ;
130
144
// 通过环境变量读取某个文件。加在到内存中
131
145
self . data . insert (
132
146
"dubbo.provider.url" . to_string ( ) ,
@@ -172,6 +186,12 @@ pub trait Config {
172
186
mod tests {
173
187
use super :: * ;
174
188
189
+ #[ test]
190
+ fn test_config ( ) {
191
+ let mut r = RootConfig :: new ( ) ;
192
+ r. test_config ( ) ;
193
+ }
194
+
175
195
#[ test]
176
196
fn test_load ( ) {
177
197
// case 1: read config yaml from default path
0 commit comments