@@ -276,13 +276,8 @@ func (s *services) SearchService(svcName, methodName string, strict bool, codecT
276276 if svc := s .knownSvcMap [svcName ]; svc != nil {
277277 return svc .svcInfo
278278 }
279- if svcName == serviceinfo .GenericService || svcName == serviceinfo .CombineServiceName {
280- // Maybe combine or generic service name,
281- // because Kitex client will write these two service name if the version is between v0.9.0-v0.9.1
282- // TODO: remove this logic if this version range is converged
283- if svcInfo := s .searchByMethodName (methodName ); svcInfo != nil {
284- return svcInfo
285- }
279+ if svcInfo := s .searchUniqueByMethodName (methodName ); svcInfo != nil {
280+ return svcInfo
286281 }
287282 }
288283 }
@@ -292,6 +287,28 @@ func (s *services) SearchService(svcName, methodName string, strict bool, codecT
292287 return nil
293288}
294289
290+ // SearchUniqueByMethodName searches for a unique service by method name.
291+ // It returns nil if there are multiple services with the same method name.
292+ func (s * services ) searchUniqueByMethodName (methodName string ) (unique * serviceinfo.ServiceInfo ) {
293+ if s .fallbackSvc != nil {
294+ // check whether fallback service has the method
295+ if mi := s .fallbackSvc .svcInfo .MethodInfo (notAllowBinaryGenericCtx , methodName ); mi != nil {
296+ unique = s .fallbackSvc .svcInfo
297+ }
298+ }
299+ // match other services
300+ for _ , svc := range s .nonFallbackSvcs {
301+ if mi := svc .svcInfo .MethodInfo (notAllowBinaryGenericCtx , methodName ); mi != nil {
302+ if unique == nil {
303+ unique = svc .svcInfo
304+ } else {
305+ return nil
306+ }
307+ }
308+ }
309+ return unique
310+ }
311+
295312// getTargetSvcInfo returns the service info if there is only one service registered.
296313func (s * services ) getTargetSvcInfo () * serviceinfo.ServiceInfo {
297314 if len (s .knownSvcMap ) != 1 {
0 commit comments