inmemory

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2022 License: MIT, Apache-2.0, BSD-2-Clause, + 4 more Imports: 22 Imported by: 0

Documentation

Index

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) GetNotifier

func (s *CacheObject) GetNotifier() *common.Notifier

获取通知对象

func (*CacheObject) GetRevision

func (s *CacheObject) GetRevision() string

获取服务对象的版本号

func (*CacheObject) IsInValid

func (s *CacheObject) IsInValid() bool

判断缓存是否不可用

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
)

func (CachedStatus) String

func (c CachedStatus) String() string

缓存状态ToString

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) Destroy

func (g *LocalCache) Destroy() error

destroy

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) GetServices

func (g *LocalCache) GetServices() model.HashSet

获取服务列表

func (*LocalCache) GetServicesByMeta

func (g *LocalCache) GetServicesByMeta(key *model.ServiceKey, includeCache bool) model.Services

func (*LocalCache) Init

func (g *LocalCache) Init(ctx *plugin.InitContext) error

Init 初始化插件

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) Name

func (g *LocalCache) Name() string

Name 插件名,一个类型下插件名唯一

func (*LocalCache) PersistMessage

func (g *LocalCache) PersistMessage(file string, message proto.Message) error

对PB缓存进行持久化

func (*LocalCache) Start

func (g *LocalCache) Start() error

启动插件

func (*LocalCache) Type

func (g *LocalCache) Type() common.Type

Type 插件类型

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

服务订阅

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL