@@ -22,7 +22,10 @@ use super::{
2222} ;
2323use crate :: common:: constant:: EMPTY_CLIENT_VERSION ;
2424use crate :: common:: model:: ClientVersion ;
25+ use crate :: config:: ConfigUtils ;
2526use crate :: grpc:: api_model:: ConnectionSetupRequest ;
27+ use crate :: grpc:: bistream_conn:: NamespaceType ;
28+ use crate :: namespace:: DEFAULT_NAMESPACE ;
2629use actix:: prelude:: * ;
2730use bean_factory:: { bean, Inject } ;
2831use inner_mem_cache:: TimeoutSet ;
@@ -31,6 +34,7 @@ pub(crate) struct ConnCacheItem {
3134 last_active_time : u64 ,
3235 conn : Addr < BiStreamConn > ,
3336 pub ( crate ) client_version : Arc < ClientVersion > ,
37+ pub ( crate ) namespace : NamespaceType ,
3438}
3539
3640impl ConnCacheItem {
@@ -39,6 +43,7 @@ impl ConnCacheItem {
3943 last_active_time,
4044 conn,
4145 client_version : EMPTY_CLIENT_VERSION . clone ( ) ,
46+ namespace : NamespaceType :: Unknown ,
4247 }
4348 }
4449}
@@ -236,6 +241,7 @@ impl Handler<BiStreamManageCmd> for BiStreamManage {
236241 item. client_version =
237242 Arc :: new ( ClientVersion :: from_string ( & client_version) ) ;
238243 }
244+ item. namespace = NamespaceType :: from_option ( request. tenant ) ;
239245 }
240246 }
241247 self . active_client ( client_id) . ok ( ) ;
@@ -260,7 +266,8 @@ impl Handler<BiStreamManageCmd> for BiStreamManage {
260266 return Ok ( BiStreamManageResult :: ClientInfo ( client_version) ) ;
261267 }
262268 BiStreamManageCmd :: NotifyConfig ( config_key, client_id_set) => {
263- let request = ConfigChangeNotifyRequest {
269+ let tenant = config_key. tenant . clone ( ) ;
270+ let mut request = ConfigChangeNotifyRequest {
264271 group : config_key. group ,
265272 data_id : config_key. data_id ,
266273 tenant : config_key. tenant ,
@@ -270,10 +277,27 @@ impl Handler<BiStreamManageCmd> for BiStreamManage {
270277 } ;
271278 let payload = Arc :: new ( PayloadUtils :: build_payload (
272279 "ConfigChangeNotifyRequest" ,
273- serde_json:: to_string ( & request) . unwrap ( ) ,
280+ serde_json:: to_string ( & request) ? ,
274281 ) ) ;
282+ let mut other_default_payload = None ;
275283 for item in & client_id_set {
276284 if let Some ( item) = self . conn_cache . get ( item) {
285+ // 默认命名空间有两个值,需要把通知的命令空间值调整为监听的值,以兼容不同版本的客户端
286+ if item. namespace . is_default ( ) && item. namespace . to_str ( ) != tenant. as_str ( )
287+ {
288+ if other_default_payload. is_none ( ) {
289+ request. tenant = Arc :: new ( item. namespace . to_str ( ) . to_string ( ) ) ;
290+ other_default_payload =
291+ Some ( Arc :: new ( PayloadUtils :: build_payload (
292+ "ConfigChangeNotifyRequest" ,
293+ serde_json:: to_string ( & request) ?,
294+ ) ) ) ;
295+ }
296+ if let Some ( payload) = other_default_payload. as_ref ( ) {
297+ item. conn . do_send ( BiStreamSenderCmd :: Send ( payload. clone ( ) ) ) ;
298+ continue ;
299+ }
300+ }
277301 item. conn . do_send ( BiStreamSenderCmd :: Send ( payload. clone ( ) ) ) ;
278302 }
279303 }
0 commit comments