store

package
v1.18.1-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 7 Imported by: 9

Documentation

Index

Constants

View Source
const (
	ElectionKeySelfServiceChecker = "polaris.checker"
	ElectionKeyMaintainJobPrefix  = "MaintainJob."
)

Variables

View Source
var (
	// StoreSlots store slots
	StoreSlots = make(map[string]Store)
)

Functions

func Error

func Error(err error) error

Error 普通error转StatusError

func NewStatusError

func NewStatusError(code StatusCode, message string) error

NewStatusError 根据code和message创建StatusError

func RegisterStore

func RegisterStore(s Store) error

RegisterStore 注册一个新的Store

func SetStoreConfig

func SetStoreConfig(conf *Config)

SetStoreConfig 设置store的conf

func TestInjectConfig added in v1.17.3

func TestInjectConfig(conf Config)

TestInjectConfig just for test

Types

type AdminStore added in v1.17.0

type AdminStore interface {
	// StartLeaderElection start leader election
	StartLeaderElection(key string) error

	// IsLeader whether it is leader node
	IsLeader(key string) bool

	// ListLeaderElections list all leaderelection
	ListLeaderElections() ([]*model.LeaderElection, error)

	// ReleaseLeaderElection force release leader status
	ReleaseLeaderElection(key string) error

	// BatchCleanDeletedInstances batch clean soft deleted instances
	BatchCleanDeletedInstances(timeout time.Duration, batchSize uint32) (uint32, error)

	// GetUnHealthyInstances get unhealthy instances which mtime time out
	GetUnHealthyInstances(timeout time.Duration, limit uint32) ([]string, error)

	// BatchCleanDeletedClients batch clean soft deleted clients
	BatchCleanDeletedClients(timeout time.Duration, batchSize uint32) (uint32, error)
}

type CircuitBreakerStore

type CircuitBreakerStore interface {
	// CreateCircuitBreakerRule create general circuitbreaker rule
	CreateCircuitBreakerRule(cbRule *model.CircuitBreakerRule) error
	// UpdateCircuitBreakerRule update general circuitbreaker rule
	UpdateCircuitBreakerRule(cbRule *model.CircuitBreakerRule) error
	// DeleteCircuitBreakerRule delete general circuitbreaker rule
	DeleteCircuitBreakerRule(id string) error
	// HasCircuitBreakerRule check circuitbreaker rule exists
	HasCircuitBreakerRule(id string) (bool, error)
	// HasCircuitBreakerRuleByName check circuitbreaker rule exists for name
	HasCircuitBreakerRuleByName(name string, namespace string) (bool, error)
	// HasCircuitBreakerRuleByNameExcludeId check circuitbreaker rule exists for name not this id
	HasCircuitBreakerRuleByNameExcludeId(name string, namespace string, id string) (bool, error)
	// GetCircuitBreakerRules get all circuitbreaker rules by query and limit
	GetCircuitBreakerRules(
		filter map[string]string, offset uint32, limit uint32) (uint32, []*model.CircuitBreakerRule, error)
	// GetCircuitBreakerRulesForCache get increment circuitbreaker rules
	GetCircuitBreakerRulesForCache(mtime time.Time, firstUpdate bool) ([]*model.CircuitBreakerRule, error)
	// EnableCircuitBreakerRule enable specific circuitbreaker rule
	EnableCircuitBreakerRule(cbRule *model.CircuitBreakerRule) error
}

CircuitBreakerStore 熔断规则的存储接口

type ClientStore

type ClientStore interface {
	// BatchAddClients insert the client info
	BatchAddClients(clients []*model.Client) error
	// BatchDeleteClients delete the client info
	BatchDeleteClients(ids []string) error
	// GetMoreClients 根据mtime获取增量clients,返回所有store的变更信息
	// 此方法用于 cache 增量更新,需要注意 mtime 应为数据库时间戳
	GetMoreClients(mtime time.Time, firstUpdate bool) (map[string]*model.Client, error)
}

ClientStore store interface for client info

type Config

type Config struct {
	Name   string
	Option map[string]interface{}
}

Config Store的通用配置

type ConfigFileGroupStore

type ConfigFileGroupStore interface {
	// CreateConfigFileGroup 创建配置文件组
	CreateConfigFileGroup(fileGroup *model.ConfigFileGroup) (*model.ConfigFileGroup, error)
	// UpdateConfigFileGroup 更新配置文件组
	UpdateConfigFileGroup(fileGroup *model.ConfigFileGroup) error
	// GetConfigFileGroup 获取单个配置文件组
	GetConfigFileGroup(namespace, name string) (*model.ConfigFileGroup, error)
	// DeleteConfigFileGroup 删除配置文件组
	DeleteConfigFileGroup(namespace, name string) error
	// GetMoreConfigGroup 获取配置分组
	GetMoreConfigGroup(firstUpdate bool, mtime time.Time) ([]*model.ConfigFileGroup, error)
	// CountConfigGroups 获取一个命名空间下的配置分组数量
	CountConfigGroups(namespace string) (uint64, error)
}

ConfigFileGroupStore 配置文件组存储接口

type ConfigFileModuleStore

ConfigFileModuleStore 配置中心模块存储接口

type ConfigFileReleaseHistoryStore

type ConfigFileReleaseHistoryStore interface {
	// CreateConfigFileReleaseHistory 创建配置文件发布历史记录
	CreateConfigFileReleaseHistory(history *model.ConfigFileReleaseHistory) error
	// QueryConfigFileReleaseHistories 获取配置文件的发布历史记录
	QueryConfigFileReleaseHistories(filter map[string]string, offset, limit uint32) (uint32, []*model.ConfigFileReleaseHistory, error)
	// CleanConfigFileReleaseHistory 清理配置发布历史
	CleanConfigFileReleaseHistory(endTime time.Time, limit uint64) error
}

ConfigFileReleaseHistoryStore 配置文件发布历史存储接口

type ConfigFileReleaseStore

type ConfigFileReleaseStore interface {
	// GetConfigFileActiveRelease	获取配置文件处于 Active 的配置发布记录
	GetConfigFileActiveRelease(file *model.ConfigFileKey) (*model.ConfigFileRelease, error)
	// GetConfigFileActiveReleaseTx	获取配置文件处于 Active 的配置发布记录
	GetConfigFileActiveReleaseTx(tx Tx, file *model.ConfigFileKey) (*model.ConfigFileRelease, error)
	// CreateConfigFileReleaseTx 创建配置文件发布
	CreateConfigFileReleaseTx(tx Tx, fileRelease *model.ConfigFileRelease) error
	// GetConfigFileRelease 获取配置文件发布内容,只获取 flag=0 的记录
	GetConfigFileRelease(req *model.ConfigFileReleaseKey) (*model.ConfigFileRelease, error)
	// GetConfigFileReleaseTx 在已开启的事务中获取配置文件发布内容,只获取 flag=0 的记录
	GetConfigFileReleaseTx(tx Tx, req *model.ConfigFileReleaseKey) (*model.ConfigFileRelease, error)
	// DeleteConfigFileReleaseTx 删除配置文件发布内容
	DeleteConfigFileReleaseTx(tx Tx, data *model.ConfigFileReleaseKey) error
	// ActiveConfigFileReleaseTx 指定激活发布的配置文件(激活具有排他性,同一个配置文件的所有 release 中只能有一个处于 active == true 状态)
	ActiveConfigFileReleaseTx(tx Tx, release *model.ConfigFileRelease) error
	// InactiveConfigFileReleaseTx 指定失效发布的配置文件(失效具有排他性,同一个配置文件的所有 release 中能有多个处于 active == false 状态)
	InactiveConfigFileReleaseTx(tx Tx, release *model.ConfigFileRelease) error
	// CleanConfigFileReleasesTx 清空配置文件发布
	CleanConfigFileReleasesTx(tx Tx, namespace, group, fileName string) error
	// GetMoreReleaseFile 获取最近更新的配置文件发布, 此方法用于 cache 增量更新,需要注意 modifyTime 应为数据库时间戳
	GetMoreReleaseFile(firstUpdate bool, modifyTime time.Time) ([]*model.ConfigFileRelease, error)
	// CountConfigReleases 获取一个配置文件组下的文件数量
	CountConfigReleases(namespace, group string, onlyActive bool) (uint64, error)
	// GetConfigFileBetaReleaseTx 获取灰度发布的配置文件信息
	GetConfigFileBetaReleaseTx(tx Tx, file *model.ConfigFileKey) (*model.ConfigFileRelease, error)
}

ConfigFileReleaseStore 配置文件发布存储接口

type ConfigFileStore

type ConfigFileStore interface {
	// LockConfigFile 加锁配置文件
	LockConfigFile(tx Tx, file *model.ConfigFileKey) (*model.ConfigFile, error)
	// CreateConfigFileTx 创建配置文件
	CreateConfigFileTx(tx Tx, file *model.ConfigFile) error
	// GetConfigFile 获取配置文件
	GetConfigFile(namespace, group, name string) (*model.ConfigFile, error)
	// GetConfigFileTx 获取配置文件
	GetConfigFileTx(tx Tx, namespace, group, name string) (*model.ConfigFile, error)
	// QueryConfigFiles 翻页查询配置文件,group、name可为模糊匹配
	QueryConfigFiles(filter map[string]string, offset uint32, limit uint32) (uint32, []*model.ConfigFile, error)
	// UpdateConfigFileTx 更新配置文件
	UpdateConfigFileTx(tx Tx, file *model.ConfigFile) error
	// DeleteConfigFileTx 删除配置文件
	DeleteConfigFileTx(tx Tx, namespace, group, name string) error
	// CountConfigFiles 获取一个配置文件组下的文件数量
	CountConfigFiles(namespace, group string) (uint64, error)
	// CountConfigFileEachGroup 统计 namespace.group 下的配置文件数量
	CountConfigFileEachGroup() (map[string]map[string]int64, error)
}

ConfigFileStore 配置文件存储接口

type ConfigFileTemplateStore

type ConfigFileTemplateStore interface {
	// QueryAllConfigFileTemplates query all config file templates
	QueryAllConfigFileTemplates() ([]*model.ConfigFileTemplate, error)
	// CreateConfigFileTemplate create config file template
	CreateConfigFileTemplate(template *model.ConfigFileTemplate) (*model.ConfigFileTemplate, error)
	// GetConfigFileTemplate get config file template by name
	GetConfigFileTemplate(name string) (*model.ConfigFileTemplate, error)
}

ConfigFileTemplateStore config file template store

type FaultDetectRuleStore added in v1.14.0

type FaultDetectRuleStore interface {
	// CreateFaultDetectRule create fault detect rule
	CreateFaultDetectRule(conf *model.FaultDetectRule) error
	// UpdateFaultDetectRule update fault detect rule
	UpdateFaultDetectRule(conf *model.FaultDetectRule) error
	// DeleteFaultDetectRule delete fault detect rule
	DeleteFaultDetectRule(id string) error
	// HasFaultDetectRule check fault detect rule exists
	HasFaultDetectRule(id string) (bool, error)
	// HasFaultDetectRuleByName check fault detect rule exists by name
	HasFaultDetectRuleByName(name string, namespace string) (bool, error)
	// HasFaultDetectRuleByNameExcludeId check fault detect rule exists by name not this id
	HasFaultDetectRuleByNameExcludeId(name string, namespace string, id string) (bool, error)
	// GetFaultDetectRules get all fault detect rules by query and limit
	GetFaultDetectRules(filter map[string]string, offset uint32, limit uint32) (uint32, []*model.FaultDetectRule, error)
	// GetFaultDetectRulesForCache get increment fault detect rules
	GetFaultDetectRulesForCache(mtime time.Time, firstUpdate bool) ([]*model.FaultDetectRule, error)
}

FaultDetectRuleStore store api for the fault detector config

type GrayStore added in v1.18.0

type GrayStore interface {
	// CleanGrayResource .
	CleanGrayResource(tx Tx, data *model.GrayResource) error
	// CreateGrayResourceTx .
	CreateGrayResourceTx(tx Tx, data *model.GrayResource) error
	// GetMoreGrayResouces .
	GetMoreGrayResouces(firstUpdate bool, mtime time.Time) ([]*model.GrayResource, error)
}

GrayStore Gray storage interface

type GroupStore

type GroupStore interface {

	// AddGroup Add a user group
	AddGroup(group *model.UserGroupDetail) error

	// UpdateGroup Update user group
	UpdateGroup(group *model.ModifyUserGroup) error

	// DeleteGroup Delete user group
	DeleteGroup(group *model.UserGroupDetail) error

	// GetGroup Get user group details
	GetGroup(id string) (*model.UserGroupDetail, error)

	// GetGroupByName Get user groups according to Name and Owner
	GetGroupByName(name, owner string) (*model.UserGroup, error)

	// GetGroups Get a list of user groups
	GetGroups(filters map[string]string, offset uint32, limit uint32) (uint32, []*model.UserGroup, error)

	// GetUserGroupsForCache Refresh of getting user groups for cache
	// 此方法用于 cache 增量更新,需要注意 mtime 应为数据库时间戳
	GetGroupsForCache(mtime time.Time, firstUpdate bool) ([]*model.UserGroupDetail, error)
}

GroupStore User group storage operation interface

type InstanceArgs

type InstanceArgs struct {
	Hosts []string
	Ports []uint32
	Meta  map[string]string
}

InstanceArgs 用于通过服务实例查询服务的参数

type InstanceMetadataRequest added in v1.17.2

type InstanceMetadataRequest struct {
	InstanceID string
	Revision   string
	Keys       []string
	Metadata   map[string]string
}

type InstanceStore

type InstanceStore interface {
	// AddInstance 增加一个实例
	AddInstance(instance *model.Instance) error
	// BatchAddInstances 增加多个实例
	BatchAddInstances(instances []*model.Instance) error
	// UpdateInstance 更新实例
	UpdateInstance(instance *model.Instance) error
	// DeleteInstance 删除一个实例,实际是把valid置为false
	DeleteInstance(instanceID string) error
	// BatchDeleteInstances 批量删除实例,flag=1
	BatchDeleteInstances(ids []interface{}) error
	// CleanInstance 清空一个实例,真正删除
	CleanInstance(instanceID string) error
	// BatchGetInstanceIsolate 检查ID是否存在,并且返回存在的ID,以及ID的隔离状态
	BatchGetInstanceIsolate(ids map[string]bool) (map[string]bool, error)
	// GetInstancesBrief 获取实例关联的token
	GetInstancesBrief(ids map[string]bool) (map[string]*model.Instance, error)
	// GetInstance 查询一个实例的详情,只返回有效的数据
	GetInstance(instanceID string) (*model.Instance, error)
	// GetInstancesCount 获取有效的实例总数
	GetInstancesCount() (uint32, error)
	// GetInstancesCountTx 获取有效的实例总数
	GetInstancesCountTx(tx Tx) (uint32, error)
	// GetInstancesMainByService 根据服务和Host获取实例(不包括metadata)
	GetInstancesMainByService(serviceID, host string) ([]*model.Instance, error)
	// GetExpandInstances 根据过滤条件查看实例详情及对应数目
	GetExpandInstances(
		filter, metaFilter map[string]string, offset uint32, limit uint32) (uint32, []*model.Instance, error)
	// GetMoreInstances 根据mtime获取增量instances,返回所有store的变更信息
	// 此方法用于 cache 增量更新,需要注意 mtime 应为数据库时间戳
	GetMoreInstances(tx Tx, mtime time.Time, firstUpdate, needMeta bool, serviceID []string) (map[string]*model.Instance, error)
	// SetInstanceHealthStatus 设置实例的健康状态
	SetInstanceHealthStatus(instanceID string, flag int, revision string) error
	// BatchSetInstanceHealthStatus 批量设置实例的健康状态
	BatchSetInstanceHealthStatus(ids []interface{}, healthy int, revision string) error
	// BatchSetInstanceIsolate 批量修改实例的隔离状态
	BatchSetInstanceIsolate(ids []interface{}, isolate int, revision string) error
	// AppendInstanceMetadata 追加实例 metadata
	BatchAppendInstanceMetadata(requests []*InstanceMetadataRequest) error
	// RemoveInstanceMetadata 删除实例指定的 metadata
	BatchRemoveInstanceMetadata(requests []*InstanceMetadataRequest) error
}

InstanceStore 实例存储接口

type L5Store

type L5Store interface {
	// GetL5Extend 获取扩展数据
	GetL5Extend(serviceID string) (map[string]interface{}, error)
	// SetL5Extend 设置meta里保存的扩展数据,并返回剩余的meta
	SetL5Extend(serviceID string, meta map[string]interface{}) (map[string]interface{}, error)
	// GenNextL5Sid 获取module
	GenNextL5Sid(layoutID uint32) (string, error)
	// GetMoreL5Extend 获取增量数据
	GetMoreL5Extend(mtime time.Time) (map[string]map[string]interface{}, error)
	// GetMoreL5Routes 获取Route增量数据
	GetMoreL5Routes(flow uint32) ([]*model.Route, error)
	// GetMoreL5Policies 获取Policy增量数据
	GetMoreL5Policies(flow uint32) ([]*model.Policy, error)
	// GetMoreL5Sections 获取Section增量数据
	GetMoreL5Sections(flow uint32) ([]*model.Section, error)
	// GetMoreL5IPConfigs 获取IP Config增量数据
	GetMoreL5IPConfigs(flow uint32) ([]*model.IPConfig, error)
}

L5Store L5扩展存储接口

type LeaderChangeEvent added in v1.14.0

type LeaderChangeEvent struct {
	Key        string
	Leader     bool
	LeaderHost string
}

LeaderChangeEvent

type NamespaceStore

type NamespaceStore interface {
	// AddNamespace Save a namespace
	AddNamespace(namespace *model.Namespace) error
	// UpdateNamespace Update namespace
	UpdateNamespace(namespace *model.Namespace) error
	// UpdateNamespaceToken Update namespace token
	UpdateNamespaceToken(name string, token string) error
	// GetNamespace Get the details of the namespace according to Name
	GetNamespace(name string) (*model.Namespace, error)
	// GetNamespaces Query Namespace from the database
	GetNamespaces(filter map[string][]string, offset, limit int) ([]*model.Namespace, uint32, error)
	// GetMoreNamespaces Get incremental data
	// 此方法用于 cache 增量更新,需要注意 mtime 应为数据库时间戳
	GetMoreNamespaces(mtime time.Time) ([]*model.Namespace, error)
}

NamespaceStore Namespace storage interface

type NamingModuleStore

type NamingModuleStore interface {
	// ServiceStore 服务接口
	ServiceStore
	// InstanceStore 实例接口
	InstanceStore
	// RoutingConfigStore 路由配置接口
	RoutingConfigStore
	// L5Store L5扩展接口
	L5Store
	// RateLimitStore 限流规则接口
	RateLimitStore
	// CircuitBreakerStore 熔断规则接口
	CircuitBreakerStore
	// ToolStore 函数及工具接口
	ToolStore
	// UserStore 用户接口
	UserStore
	// GroupStore 用户组接口
	GroupStore
	// StrategyStore 鉴权策略接口
	StrategyStore
	// RoutingConfigStoreV2 路由策略 v2 接口
	RoutingConfigStoreV2
	// FaultDetectRuleStore fault detect rule interface
	FaultDetectRuleStore
	// ServiceContractStore 服务契约操作接口
	ServiceContractStore
}

NamingModuleStore Service discovery, governance center module storage interface

type RateLimitStore

type RateLimitStore interface {
	// CreateRateLimit 新增限流规则
	CreateRateLimit(limiting *model.RateLimit) error
	// UpdateRateLimit 更新限流规则
	UpdateRateLimit(limiting *model.RateLimit) error
	// EnableRateLimit 启用限流规则
	EnableRateLimit(limit *model.RateLimit) error
	// DeleteRateLimit 删除限流规则
	DeleteRateLimit(limiting *model.RateLimit) error
	// GetExtendRateLimits 根据过滤条件拉取限流规则
	GetExtendRateLimits(query map[string]string, offset uint32, limit uint32) (uint32, []*model.ExtendRateLimit, error)
	// GetRateLimitWithID 根据限流ID拉取限流规则
	GetRateLimitWithID(id string) (*model.RateLimit, error)
	// GetRateLimitsForCache 根据修改时间拉取增量限流规则及最新版本号
	// 此方法用于 cache 增量更新,需要注意 mtime 应为数据库时间戳
	GetRateLimitsForCache(mtime time.Time, firstUpdate bool) ([]*model.RateLimit, error)
}

RateLimitStore 限流规则的存储接口

type RoutingConfigStore

type RoutingConfigStore interface {
	// CreateRoutingConfig 新增一个路由配置
	CreateRoutingConfig(conf *model.RoutingConfig) error
	// UpdateRoutingConfig 更新一个路由配置
	UpdateRoutingConfig(conf *model.RoutingConfig) error
	// DeleteRoutingConfig 删除一个路由配置
	DeleteRoutingConfig(serviceID string) error
	// DeleteRoutingConfigTx 删除一个路由配置
	DeleteRoutingConfigTx(tx Tx, serviceID string) error
	// GetRoutingConfigsForCache 通过mtime拉取增量的路由配置信息
	// 此方法用于 cache 增量更新,需要注意 mtime 应为数据库时间戳
	GetRoutingConfigsForCache(mtime time.Time, firstUpdate bool) ([]*model.RoutingConfig, error)
	// GetRoutingConfigWithService 根据服务名和命名空间拉取路由配置
	GetRoutingConfigWithService(name string, namespace string) (*model.RoutingConfig, error)
	// GetRoutingConfigWithID 根据服务ID拉取路由配置
	GetRoutingConfigWithID(id string) (*model.RoutingConfig, error)
	// GetRoutingConfigs 查询路由配置列表
	GetRoutingConfigs(filter map[string]string, offset uint32, limit uint32) (uint32, []*model.ExtendRoutingConfig, error)
}

RoutingConfigStore 路由配置表的存储接口

type RoutingConfigStoreV2

type RoutingConfigStoreV2 interface {
	// EnableRouting 设置路由规则是否启用
	EnableRouting(conf *model.RouterConfig) error
	// CreateRoutingConfigV2 新增一个路由配置
	CreateRoutingConfigV2(conf *model.RouterConfig) error
	// CreateRoutingConfigV2Tx 新增一个路由配置
	CreateRoutingConfigV2Tx(tx Tx, conf *model.RouterConfig) error
	// UpdateRoutingConfigV2 更新一个路由配置
	UpdateRoutingConfigV2(conf *model.RouterConfig) error
	// UpdateRoutingConfigV2Tx 更新一个路由配置
	UpdateRoutingConfigV2Tx(tx Tx, conf *model.RouterConfig) error
	// DeleteRoutingConfigV2 删除一个路由配置
	DeleteRoutingConfigV2(serviceID string) error
	// GetRoutingConfigsV2ForCache 通过mtime拉取增量的路由配置信息
	// 此方法用于 cache 增量更新,需要注意 mtime 应为数据库时间戳
	GetRoutingConfigsV2ForCache(mtime time.Time, firstUpdate bool) ([]*model.RouterConfig, error)
	// GetRoutingConfigV2WithID 根据服务ID拉取路由配置
	GetRoutingConfigV2WithID(id string) (*model.RouterConfig, error)
	// GetRoutingConfigV2WithIDTx 根据服务ID拉取路由配置
	GetRoutingConfigV2WithIDTx(tx Tx, id string) (*model.RouterConfig, error)
}

RoutingConfigStoreV2 路由配置表的存储接口

type ServiceContractStore added in v1.18.0

type ServiceContractStore interface {
	// CreateServiceContract 创建服务契约
	CreateServiceContract(contract *model.ServiceContract) error
	// UpdateServiceContract 更新服务契约
	UpdateServiceContract(contract *model.ServiceContract) error
	// DeleteServiceContract 删除服务契约
	DeleteServiceContract(contract *model.ServiceContract) error
	// GetMoreServiceContracts 用于缓存加载数据
	GetMoreServiceContracts(firstUpdate bool, mtime time.Time) ([]*model.EnrichServiceContract, error)
	// GetServiceContract 查询服务契约数据
	GetServiceContract(id string) (data *model.EnrichServiceContract, err error)
	// AddServiceContractInterfaces 创建服务契约API接口
	AddServiceContractInterfaces(contract *model.EnrichServiceContract) error
	// AppendServiceContractInterfaces 追加服务契约API接口
	AppendServiceContractInterfaces(contract *model.EnrichServiceContract) error
	// DeleteServiceContractInterfaces 批量删除服务契约API接口
	DeleteServiceContractInterfaces(contract *model.EnrichServiceContract) error
}

type ServiceStore

type ServiceStore interface {
	// AddService 保存一个服务
	AddService(service *model.Service) error
	// DeleteService 删除服务
	DeleteService(id, serviceName, namespaceName string) error
	// DeleteServiceAlias 删除服务别名
	DeleteServiceAlias(name string, namespace string) error
	// UpdateServiceAlias 修改服务别名
	UpdateServiceAlias(alias *model.Service, needUpdateOwner bool) error
	// UpdateService 更新服务
	UpdateService(service *model.Service, needUpdateOwner bool) error
	// UpdateServiceToken 更新服务token
	UpdateServiceToken(serviceID string, token string, revision string) error
	// GetSourceServiceToken 获取源服务的token信息
	GetSourceServiceToken(name string, namespace string) (*model.Service, error)
	// GetService 根据服务名和命名空间获取服务的详情
	GetService(name string, namespace string) (*model.Service, error)
	// GetServiceByID 根据服务ID查询服务详情
	GetServiceByID(id string) (*model.Service, error)
	// GetServices 根据相关条件查询对应服务及数目
	GetServices(serviceFilters, serviceMetas map[string]string, instanceFilters *InstanceArgs, offset, limit uint32) (
		uint32, []*model.Service, error)
	// GetServicesCount 获取所有服务总数
	GetServicesCount() (uint32, error)
	// GetMoreServices 获取增量services
	// 此方法用于 cache 增量更新,需要注意 mtime 应为数据库时间戳
	GetMoreServices(mtime time.Time, firstUpdate, disableBusiness, needMeta bool) (map[string]*model.Service, error)
	// GetServiceAliases 获取服务别名列表
	GetServiceAliases(filter map[string]string, offset uint32, limit uint32) (uint32, []*model.ServiceAlias, error)
	// GetSystemServices 获取系统服务
	GetSystemServices() ([]*model.Service, error)
	// GetServicesBatch 批量获取服务id、负责人等信息
	GetServicesBatch(services []*model.Service) ([]*model.Service, error)
}

ServiceStore 服务存储接口

type StatusCode

type StatusCode uint32

StatusCode 存储层的状态码

const (
	Ok StatusCode = iota
	// 参数不合法
	EmptyParamsErr
	// 数据不合法,比如越级了,超过了字段大小
	OutOfRangeErr
	// 数据冲突,在并发更新metadata的时候可能会出现
	DataConflictErr
	// 找不到namespace,service插入依赖namespace是否存在
	NotFoundNamespace
	// 找不到service,在instance等资源插入的时候依赖service是否存在
	NotFoundService
	// 在标记规则前,需要保证规则的master版本存在
	NotFoundMasterConfig
	// 在发布规则前,需要保证规则已标记且服务存在
	NotFoundTagConfigOrService
	// 在删除规则时,发现存在已经发布的版本
	ExistReleasedConfig
	// 操作的行数与预期不符合
	AffectedRowsNotMatch
	// 主键重复,一般是资源已存在了,提醒用户资源存在
	DuplicateEntryErr
	// 外键错误,一般是操作不当导致的
	ForeignKeyErr
	// 数据库死锁
	DeadlockErr
	// 网格订阅服务的时候,网格或者服务不存在
	NotFoundMeshOrService
	// 更新订阅服务的时候,订阅服务不存在
	NotFoundMeshService
	// Failed to find target CircuitBreaker
	NotFoundCircuitBreaker
	// Failed to find fuse breaker information associated with service
	NotFoundReleaseCircuitBreaker
	Unknown
	// 用户不存在
	NotFoundUser
	// 用户组不存在
	NotFoundUserGroup
	// 非法的用户ID列表
	InvalidUserIDSlice
	NotFoundResource
)

状态码定义

func Code

func Code(err error) StatusCode

Code 根据error接口,获取状态码

type StatusError

type StatusError struct {
	// contains filtered or unexported fields
}

StatusError 包括了状态码的error接口

func (*StatusError) Error

func (s *StatusError) Error() string

Error 实现error接口

type Store

type Store interface {
	// Name 存储层的名字
	Name() string
	// Initialize 存储的初始化函数
	Initialize(c *Config) error
	// Destroy 存储的析构函数
	Destroy() error
	// CreateTransaction 创建事务对象
	CreateTransaction() (Transaction, error)
	// StartTx 开启一个原子事务
	StartTx() (Tx, error)
	// StartReadTx 开启一个原子事务
	StartReadTx() (Tx, error)
	// NamespaceStore Service namespace interface
	NamespaceStore
	// NamingModuleStore Service Registration Discovery Module Storage Interface
	NamingModuleStore
	// ConfigFileModuleStore Configure the central module storage interface
	ConfigFileModuleStore
	// ClientStore Client the central module storage interface
	ClientStore
	// AdminStore Maintain inteface
	AdminStore
	// GrayStore mgr gray resource
	GrayStore
}

Store 通用存储接口

func GetStore

func GetStore() (Store, error)

GetStore 获取Store

func TestGetStore

func TestGetStore() (Store, error)

TestGetStore 获取Store

type StrategyStore

type StrategyStore interface {

	// AddStrategy Create authentication strategy
	AddStrategy(strategy *model.StrategyDetail) error

	// UpdateStrategy Update authentication strategy
	UpdateStrategy(strategy *model.ModifyStrategyDetail) error

	// DeleteStrategy Delete authentication strategy
	DeleteStrategy(id string) error

	// LooseAddStrategyResources Song requires the resources of the authentication strategy,
	//   allowing the issue of ignoring the primary key conflict
	LooseAddStrategyResources(resources []model.StrategyResource) error

	// RemoveStrategyResources Clean all the strategies associated with corresponding resources
	RemoveStrategyResources(resources []model.StrategyResource) error

	// GetStrategyResources Gets a Principal's corresponding resource ID data information
	GetStrategyResources(principalId string, principalRole model.PrincipalType) ([]model.StrategyResource, error)

	// GetDefaultStrategyDetailByPrincipal Get a default policy for a Principal
	GetDefaultStrategyDetailByPrincipal(principalId string,
		principalType model.PrincipalType) (*model.StrategyDetail, error)

	// GetStrategyDetail Get strategy details
	GetStrategyDetail(id string) (*model.StrategyDetail, error)

	// GetStrategies Get a list of strategies
	GetStrategies(filters map[string]string, offset uint32, limit uint32) (uint32,
		[]*model.StrategyDetail, error)

	// GetStrategyDetailsForCache Used to refresh policy cache
	// 此方法用于 cache 增量更新,需要注意 mtime 应为数据库时间戳
	GetStrategyDetailsForCache(mtime time.Time, firstUpdate bool) ([]*model.StrategyDetail, error)
}

StrategyStore Authentication policy related storage operation interface

type ToolStore

type ToolStore interface {
	// GetUnixSecond Get the current time
	GetUnixSecond(maxWait time.Duration) (int64, error)
}

ToolStore Storage related functions and tool interfaces

type Transaction

type Transaction interface {
	// Commit Transaction
	Commit() error
	// LockBootstrap Start the lock, limit the concurrent number of Server boot
	LockBootstrap(key string, server string) error
	// LockNamespace Row it locks Namespace
	LockNamespace(name string) (*model.Namespace, error)
	// DeleteNamespace Delete Namespace
	DeleteNamespace(name string) error
	// LockService Row it locks service
	LockService(name string, namespace string) (*model.Service, error)
	// RLockService Shared lock service
	RLockService(name string, namespace string) (*model.Service, error)
}

Transaction Transaction interface, does not support multi-level concurrency operation, currently only support a single price serial operation

type Tx

type Tx interface {
	// Commit Transaction
	Commit() error
	// Rollback transaction
	Rollback() error
	// GetDelegateTx Get the original proxy transaction object.Different storage types have no business implementation
	GetDelegateTx() interface{}
	// CreateReadView create a snapshot read view
	CreateReadView() error
}

Tx Atomic matters without any business attributes.Abstraction of different storage type transactions

type UserStore

type UserStore interface {
	// AddUser Create a user
	AddUser(user *model.User) error
	// UpdateUser Update user
	UpdateUser(user *model.User) error
	// DeleteUser delete users
	DeleteUser(user *model.User) error
	// GetSubCount Number of getting a child account
	GetSubCount(user *model.User) (uint32, error)
	// GetUser Obtain user
	GetUser(id string) (*model.User, error)
	// GetUserByName Get a unique user according to Name + Owner
	GetUserByName(name, ownerId string) (*model.User, error)
	// GetUserByIDS Get users according to USER IDS batch
	GetUserByIds(ids []string) ([]*model.User, error)
	// GetUsers Query user list
	GetUsers(filters map[string]string, offset uint32, limit uint32) (uint32, []*model.User, error)
	// GetUsersForCache Used to refresh user cache
	// 此方法用于 cache 增量更新,需要注意 mtime 应为数据库时间戳
	GetUsersForCache(mtime time.Time, firstUpdate bool) ([]*model.User, error)
}

UserStore User-related operation interface

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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