Documentation ¶
Index ¶
- Variables
- type CacheHandlers
- type CacheObject
- func (s *CacheObject) GetBusiness() string
- func (s *CacheObject) GetMeshConfig() *namingpb.MeshConfig
- func (s *CacheObject) GetMeshResource() *namingpb.MeshResource
- func (s *CacheObject) GetNotifier() *common.Notifier
- func (s *CacheObject) GetRevision() string
- func (s *CacheObject) IsInValid() bool
- func (s *CacheObject) LoadValue(updateVisitTime bool) interface{}
- func (s *CacheObject) MakeInValid(err model.SDKError)
- func (s *CacheObject) OnServiceUpdate(event *serverconnector.ServiceEvent) bool
- func (s *CacheObject) SetValue(cacheValue model.RegistryValue)
- type CachedStatus
- type LocalCache
- func (g *LocalCache) CreateDefaultInstanceLocalValue(instId string) local.InstanceLocalValue
- func (g *LocalCache) Destroy() error
- func (g *LocalCache) GetInstances(svcKey *model.ServiceKey, includeCache bool, isInternalRequest bool) model.ServiceInstances
- func (g *LocalCache) GetMesh(key *model.ServiceKey, includeCache bool) model.Mesh
- func (g *LocalCache) GetMeshConfig(key *model.ServiceKey, includeCache bool) model.MeshConfig
- func (g *LocalCache) GetMeshConfigImp(svcEventKey *model.ServiceEventKey, includeCache bool) model.MeshConfig
- func (g *LocalCache) GetMeshImp(svcEventKey *model.ServiceEventKey, includeCache bool) model.Mesh
- func (g *LocalCache) GetServiceRateLimitRule(key *model.ServiceKey, includeCache bool) model.ServiceRule
- func (g *LocalCache) GetServiceRouteRule(key *model.ServiceKey, includeCache bool) model.ServiceRule
- func (g *LocalCache) GetServiceRule(svcEventKey *model.ServiceEventKey, includeCache bool) model.ServiceRule
- func (g *LocalCache) GetServices() model.HashSet
- func (g *LocalCache) GetServicesByMeta(key *model.ServiceKey, includeCache bool) model.Services
- func (g *LocalCache) Init(ctx *plugin.InitContext) error
- func (g *LocalCache) LoadInstances(svcKey *model.ServiceKey) (*common.Notifier, error)
- func (g *LocalCache) LoadMesh(key *model.ServiceKey) (*common.Notifier, error)
- func (g *LocalCache) LoadMeshConfig(key *model.ServiceKey) (*common.Notifier, error)
- func (g *LocalCache) LoadPersistedMessage(file string, msg proto.Message) error
- func (g *LocalCache) LoadServiceRateLimitRule(key *model.ServiceKey) (*common.Notifier, error)
- func (g *LocalCache) LoadServiceRouteRule(key *model.ServiceKey) (*common.Notifier, error)
- func (g *LocalCache) LoadServiceRule(svcEventKey *model.ServiceEventKey) (*common.Notifier, error)
- func (g *LocalCache) LoadServices(key *model.ServiceKey) (*common.Notifier, error)
- func (g *LocalCache) Name() string
- func (g *LocalCache) PersistMessage(file string, message proto.Message) error
- func (g *LocalCache) Start() error
- func (g *LocalCache) Type() common.Type
- func (g *LocalCache) UpdateInstances(svcUpdateReq *localregistry.ServiceUpdateRequest) error
- func (g *LocalCache) WatchService(svcEventKey *model.ServiceEventKey) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( CachedStatusToPresent = map[CachedStatus]string{ CacheNotExists: "CacheNotExists", CacheChanged: "CacheChanged", CacheNotChanged: "CacheNotChanged", } )
Functions ¶
This section is empty.
Types ¶
type CacheHandlers ¶
type CacheHandlers struct { // 消息比较,返回比较结果 CompareMessage func(cacheValue interface{}, newMessage proto.Message) CachedStatus // 原始消息转换为缓存对象 MessageToCacheValue func(cacheValue interface{}, newMessage proto.Message, svcLocalValue local.ServiceLocalValue, cacheLoaded bool) model.RegistryValue // 缓存被删除 OnEventDeleted func(key *model.ServiceEventKey, cacheValue interface{}) // 缓存更新的后续擦欧洲哦 PostCacheUpdated func(svcKey *model.ServiceEventKey, newCacheValue interface{}, preCacheStatus CachedStatus) }
不同的事件回调函数
type CacheObject ¶
type CacheObject struct { Handler CacheHandlers // contains filtered or unexported fields }
缓存值的管理基类
func NewCacheObject ¶
func NewCacheObject( handler CacheHandlers, registry *LocalCache, serviceValueKey *model.ServiceEventKey) *CacheObject
创建缓存对象
func NewCacheObjectWithInitValue ¶
func NewCacheObjectWithInitValue(handler CacheHandlers, registry *LocalCache, serviceValueKey *model.ServiceEventKey, message proto.Message) *CacheObject
创建带初始值的缓存对象
func (*CacheObject) GetBusiness ¶
func (s *CacheObject) GetBusiness() string
func (*CacheObject) GetMeshConfig ¶
func (s *CacheObject) GetMeshConfig() *namingpb.MeshConfig
func (*CacheObject) GetMeshResource ¶
func (s *CacheObject) GetMeshResource() *namingpb.MeshResource
func (*CacheObject) LoadValue ¶
func (s *CacheObject) LoadValue(updateVisitTime bool) interface{}
判断缓存值是否可读取
func (*CacheObject) MakeInValid ¶
func (s *CacheObject) MakeInValid(err model.SDKError)
将本缓存值为不可用,只用于首次请求时,向后端connector监听失败的场景
func (*CacheObject) OnServiceUpdate ¶
func (s *CacheObject) OnServiceUpdate(event *serverconnector.ServiceEvent) bool
服务远程实例更新事件到来后的回调操作
func (*CacheObject) SetValue ¶
func (s *CacheObject) SetValue(cacheValue model.RegistryValue)
设置缓存对象
type CachedStatus ¶
type CachedStatus int
缓存状态
const ( CacheNotExists CachedStatus = iota + 1 CacheChanged CacheNotChanged // cache是空的,但是server没有返回data CacheEmptyButNoData )
type LocalCache ¶
type LocalCache struct { *plugin.PluginBase *common.RunContext // contains filtered or unexported fields }
LocalCache 基于内存的本地缓存策略
func (*LocalCache) CreateDefaultInstanceLocalValue ¶
func (g *LocalCache) CreateDefaultInstanceLocalValue(instId string) local.InstanceLocalValue
创建默认的实例本地信息
func (*LocalCache) GetInstances ¶
func (g *LocalCache) GetInstances(svcKey *model.ServiceKey, includeCache bool, isInternalRequest bool) model.ServiceInstances
GetInstances 获取服务实例列表
func (*LocalCache) GetMesh ¶
func (g *LocalCache) GetMesh(key *model.ServiceKey, includeCache bool) model.Mesh
非阻塞获取网格
func (*LocalCache) GetMeshConfig ¶
func (g *LocalCache) GetMeshConfig(key *model.ServiceKey, includeCache bool) model.MeshConfig
非阻塞获取网格规则
func (*LocalCache) GetMeshConfigImp ¶
func (g *LocalCache) GetMeshConfigImp(svcEventKey *model.ServiceEventKey, includeCache bool) model.MeshConfig
非阻塞获取网格规则具体逻辑
func (*LocalCache) GetMeshImp ¶
func (g *LocalCache) GetMeshImp(svcEventKey *model.ServiceEventKey, includeCache bool) model.Mesh
非阻塞获取网格具体逻辑
func (*LocalCache) GetServiceRateLimitRule ¶
func (g *LocalCache) GetServiceRateLimitRule(key *model.ServiceKey, includeCache bool) model.ServiceRule
非阻塞获取限流规则
func (*LocalCache) GetServiceRouteRule ¶
func (g *LocalCache) GetServiceRouteRule(key *model.ServiceKey, includeCache bool) model.ServiceRule
非阻塞获取配置信息
func (*LocalCache) GetServiceRule ¶
func (g *LocalCache) GetServiceRule(svcEventKey *model.ServiceEventKey, includeCache bool) model.ServiceRule
非阻塞获取规则信息
func (*LocalCache) GetServicesByMeta ¶
func (g *LocalCache) GetServicesByMeta(key *model.ServiceKey, includeCache bool) model.Services
func (*LocalCache) LoadInstances ¶
func (g *LocalCache) LoadInstances(svcKey *model.ServiceKey) (*common.Notifier, error)
LoadInstances 发起实例查询
func (*LocalCache) LoadMesh ¶
func (g *LocalCache) LoadMesh(key *model.ServiceKey) (*common.Notifier, error)
非阻塞加载网格
func (*LocalCache) LoadMeshConfig ¶
func (g *LocalCache) LoadMeshConfig(key *model.ServiceKey) (*common.Notifier, error)
非阻塞加载网格规则
func (*LocalCache) LoadPersistedMessage ¶
func (g *LocalCache) LoadPersistedMessage(file string, msg proto.Message) error
从文件中加载PB缓存
func (*LocalCache) LoadServiceRateLimitRule ¶
func (g *LocalCache) LoadServiceRateLimitRule(key *model.ServiceKey) (*common.Notifier, error)
非阻塞发起限流规则加载
func (*LocalCache) LoadServiceRouteRule ¶
func (g *LocalCache) LoadServiceRouteRule(key *model.ServiceKey) (*common.Notifier, error)
非阻塞发起配置加载
func (*LocalCache) LoadServiceRule ¶
func (g *LocalCache) LoadServiceRule(svcEventKey *model.ServiceEventKey) (*common.Notifier, error)
非阻塞发起规则加载
func (*LocalCache) LoadServices ¶
func (g *LocalCache) LoadServices(key *model.ServiceKey) (*common.Notifier, error)
非阻塞加载批量服务
func (*LocalCache) PersistMessage ¶
func (g *LocalCache) PersistMessage(file string, message proto.Message) error
对PB缓存进行持久化
func (*LocalCache) UpdateInstances ¶
func (g *LocalCache) UpdateInstances(svcUpdateReq *localregistry.ServiceUpdateRequest) error
UpdateInstances 批量更新服务实例状态,properties存放的是状态值,当前支持2个key 对同一个key的更新,请保持线程安全 1. ReadyToServe: 故障熔断标识,true or false 2. DynamicWeight:动态权重值
func (*LocalCache) WatchService ¶
func (g *LocalCache) WatchService(svcEventKey *model.ServiceEventKey) error
服务订阅
Click to show internal directories.
Click to hide internal directories.