@@ -254,15 +254,19 @@ func (svr *serverAuthAbility) queryServiceResource(
254
254
svcSet := model .NewServiceSet ()
255
255
256
256
for index := range req {
257
- names .Add (req [index ].Namespace .GetValue ())
258
- svc := svr .Cache ().Service ().GetServiceByName (req [index ].Name .GetValue (), req [index ].Namespace .GetValue ())
257
+ svcName := req [index ].GetName ().GetValue ()
258
+ svcNamespace := req [index ].GetNamespace ().GetValue ()
259
+ names .Add (svcNamespace )
260
+ svc := svr .Cache ().Service ().GetServiceByName (svcName , svcNamespace )
259
261
if svc != nil {
260
262
svcSet .Add (svc )
261
263
}
262
264
}
263
265
264
266
ret := svr .convertToDiscoverResourceEntryMaps (names , svcSet )
265
- authLog .Debug ("[Auth][Server] collect service access res" , zap .Any ("res" , ret ))
267
+ if authLog .DebugEnabled () {
268
+ authLog .Debug ("[Auth][Server] collect service access res" , zap .Any ("res" , ret ))
269
+ }
266
270
return ret
267
271
}
268
272
@@ -277,9 +281,11 @@ func (svr *serverAuthAbility) queryServiceAliasResource(
277
281
svcSet := model .NewServiceSet ()
278
282
279
283
for index := range req {
280
- names .Add (req [index ].Namespace .GetValue ())
281
- alias := svr .Cache ().Service ().GetServiceByName (req [index ].Alias .GetValue (),
282
- req [index ].AliasNamespace .GetValue ())
284
+ aliasSvcName := req [index ].GetAlias ().GetValue ()
285
+ aliasSvcNamespace := req [index ].GetAliasNamespace ().GetValue ()
286
+ svcNamespace := req [index ].GetNamespace ().GetValue ()
287
+ names .Add (svcNamespace )
288
+ alias := svr .Cache ().Service ().GetServiceByName (aliasSvcName , aliasSvcNamespace )
283
289
if alias != nil {
284
290
svc := svr .Cache ().Service ().GetServiceByID (alias .Reference )
285
291
if svc != nil {
@@ -289,7 +295,9 @@ func (svr *serverAuthAbility) queryServiceAliasResource(
289
295
}
290
296
291
297
ret := svr .convertToDiscoverResourceEntryMaps (names , svcSet )
292
- authLog .Debug ("[Auth][Server] collect service alias access res" , zap .Any ("res" , ret ))
298
+ if authLog .DebugEnabled () {
299
+ authLog .Debug ("[Auth][Server] collect service alias access res" , zap .Any ("res" , ret ))
300
+ }
293
301
return ret
294
302
}
295
303
@@ -305,14 +313,15 @@ func (svr *serverAuthAbility) queryInstanceResource(
305
313
svcSet := model .NewServiceSet ()
306
314
307
315
for index := range req {
316
+ svcName := req [index ].GetService ().GetValue ()
317
+ svcNamespace := req [index ].GetNamespace ().GetValue ()
308
318
item := req [index ]
309
- if item .Namespace .GetValue () != "" && item .Service .GetValue () != "" {
310
- svc := svr .Cache ().Service ().GetServiceByName (req [index ].Service .GetValue (),
311
- req [index ].Namespace .GetValue ())
319
+ if svcNamespace != "" && svcName != "" {
320
+ svc := svr .Cache ().Service ().GetServiceByName (svcName , svcNamespace )
312
321
if svc != nil {
313
322
svcSet .Add (svc )
314
323
} else {
315
- names .Add (req [ index ]. Namespace . GetValue () )
324
+ names .Add (svcNamespace )
316
325
}
317
326
} else {
318
327
ins := svr .Cache ().Instance ().GetInstance (item .GetId ().GetValue ())
@@ -321,14 +330,16 @@ func (svr *serverAuthAbility) queryInstanceResource(
321
330
if svc != nil {
322
331
svcSet .Add (svc )
323
332
} else {
324
- names .Add (req [ index ]. Namespace . GetValue () )
333
+ names .Add (svcNamespace )
325
334
}
326
335
}
327
336
}
328
337
}
329
338
330
339
ret := svr .convertToDiscoverResourceEntryMaps (names , svcSet )
331
- authLog .Debug ("[Auth][Server] collect instance access res" , zap .Any ("res" , ret ))
340
+ if authLog .DebugEnabled () {
341
+ authLog .Debug ("[Auth][Server] collect instance access res" , zap .Any ("res" , ret ))
342
+ }
332
343
return ret
333
344
}
334
345
@@ -343,14 +354,17 @@ func (svr *serverAuthAbility) queryCircuitBreakerResource(
343
354
svcSet := model .NewServiceSet ()
344
355
345
356
for index := range req {
346
- svc := svr .Cache ().Service ().GetServiceByName (req [index ].Service .GetValue (),
347
- req [index ].Namespace .GetValue ())
357
+ svcName := req [index ].GetService ().GetValue ()
358
+ svcNamespace := req [index ].GetNamespace ().GetValue ()
359
+ svc := svr .Cache ().Service ().GetServiceByName (svcName , svcNamespace )
348
360
if svc != nil {
349
361
svcSet .Add (svc )
350
362
}
351
363
}
352
364
ret := svr .convertToDiscoverResourceEntryMaps (names , svcSet )
353
- authLog .Debug ("[Auth][Server] collect circuit-breaker access res" , zap .Any ("res" , ret ))
365
+ if authLog .DebugEnabled () {
366
+ authLog .Debug ("[Auth][Server] collect circuit-breaker access res" , zap .Any ("res" , ret ))
367
+ }
354
368
return ret
355
369
}
356
370
@@ -365,15 +379,18 @@ func (svr *serverAuthAbility) queryCircuitBreakerReleaseResource(
365
379
svcSet := model .NewServiceSet ()
366
380
367
381
for index := range req {
368
- svc := svr .Cache ().Service ().GetServiceByName (req [index ].Service .Name .GetValue (),
369
- req [index ].Service .Namespace .GetValue ())
382
+ svcName := req [index ].GetService ().GetName ().GetValue ()
383
+ svcNamespace := req [index ].GetService ().GetNamespace ().GetValue ()
384
+ svc := svr .Cache ().Service ().GetServiceByName (svcName , svcNamespace )
370
385
if svc != nil {
371
386
svcSet .Add (svc )
372
387
}
373
388
}
374
389
375
390
ret := svr .convertToDiscoverResourceEntryMaps (names , svcSet )
376
- authLog .Debug ("[Auth][Server] collect circuit-breaker-release access res" , zap .Any ("res" , ret ))
391
+ if authLog .DebugEnabled () {
392
+ authLog .Debug ("[Auth][Server] collect circuit-breaker-release access res" , zap .Any ("res" , ret ))
393
+ }
377
394
return ret
378
395
}
379
396
@@ -388,15 +405,18 @@ func (svr *serverAuthAbility) queryRouteRuleResource(
388
405
svcSet := model .NewServiceSet ()
389
406
390
407
for index := range req {
391
- svc := svr .Cache ().Service ().GetServiceByName (req [index ].Service .GetValue (),
392
- req [index ].Namespace .GetValue ())
408
+ svcName := req [index ].GetService ().GetValue ()
409
+ svcNamespace := req [index ].GetNamespace ().GetValue ()
410
+ svc := svr .Cache ().Service ().GetServiceByName (svcName , svcNamespace )
393
411
if svc != nil {
394
412
svcSet .Add (svc )
395
413
}
396
414
}
397
415
398
416
ret := svr .convertToDiscoverResourceEntryMaps (names , svcSet )
399
- authLog .Debug ("[Auth][Server] collect route-rule access res" , zap .Any ("res" , ret ))
417
+ if authLog .DebugEnabled () {
418
+ authLog .Debug ("[Auth][Server] collect route-rule access res" , zap .Any ("res" , ret ))
419
+ }
400
420
return ret
401
421
}
402
422
@@ -411,15 +431,18 @@ func (svr *serverAuthAbility) queryRateLimitConfigResource(
411
431
svcSet := model .NewServiceSet ()
412
432
413
433
for index := range req {
414
- svc := svr .Cache ().Service ().GetServiceByName (req [index ].Service .GetValue (),
415
- req [index ].Namespace .GetValue ())
434
+ svcName := req [index ].GetService ().GetValue ()
435
+ svcNamespace := req [index ].GetNamespace ().GetValue ()
436
+ svc := svr .Cache ().Service ().GetServiceByName (svcName , svcNamespace )
416
437
if svc != nil {
417
438
svcSet .Add (svc )
418
439
}
419
440
}
420
441
421
442
ret := svr .convertToDiscoverResourceEntryMaps (names , svcSet )
422
- authLog .Debug ("[Auth][Server] collect rate-limit access res" , zap .Any ("res" , ret ))
443
+ if authLog .DebugEnabled () {
444
+ authLog .Debug ("[Auth][Server] collect rate-limit access res" , zap .Any ("res" , ret ))
445
+ }
423
446
return ret
424
447
}
425
448
0 commit comments