功能概述
istio-proxy主要的功能是连接istio的控制面组件和envoy之间的交互,其中check的功能是将envoy收集的attributes信息上报给mixer,在istio中有几十种attributes(官方文档中有Attribute Vocabulary的具体介绍), mixer根据自身的adapter给envoy 反馈。为了避免每次对mixer都进行远程调用,保证运行时的性能,在istio-proxy这里配置了本地缓存。
具体实现
在proxy这里配置了两层缓存,分别是referenced map和LRUcache,定义在check_cache.h中:
Referenced map是用来存储envoy check之后mixer的返回的属性,也就是mixer的adapter所使用到的所有属性。
LRUCache是用来储存每次对mixer请求之后所得到的check的结果。
步骤简析
缓存检查
cache->Check(attributes, result);
if (result->IsCacheHit()) return result->Status();
未命中缓存,发起远程连接并且接受mixer回复.
result->SetReponse(status, response);
return result->Status();
代码解读: