store

package
v1.13.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 8 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func Error

func Error(err error) error

Error 普通error转StatusError

func IsWildName

func IsWildName(name string) bool

IsWildName 判断名字是否为通配名字,只支持前缀索引(名字最后为*)

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

Types

type CircuitBreakerStore

type CircuitBreakerStore interface {
	// CreateCircuitBreaker 新增熔断规则
	CreateCircuitBreaker(circuitBreaker *model.CircuitBreaker) error

	// TagCircuitBreaker 标记熔断规则
	TagCircuitBreaker(circuitBreaker *model.CircuitBreaker) error

	// ReleaseCircuitBreaker 发布熔断规则
	ReleaseCircuitBreaker(circuitBreakerRelation *model.CircuitBreakerRelation) error

	// UnbindCircuitBreaker 解绑熔断规则
	UnbindCircuitBreaker(serviceID, ruleID, ruleVersion string) error

	// DeleteTagCircuitBreaker 删除已标记熔断规则
	DeleteTagCircuitBreaker(id string, version string) error

	// DeleteMasterCircuitBreaker 删除master熔断规则
	DeleteMasterCircuitBreaker(id string) error

	// UpdateCircuitBreaker 修改熔断规则
	UpdateCircuitBreaker(circuitBraker *model.CircuitBreaker) error

	// GetCircuitBreaker 获取熔断规则
	GetCircuitBreaker(id, version string) (*model.CircuitBreaker, error)

	// GetCircuitBreakerVersions 获取熔断规则的所有版本
	GetCircuitBreakerVersions(id string) ([]string, error)

	// GetCircuitBreakerMasterRelation 获取熔断规则master版本的绑定关系
	GetCircuitBreakerMasterRelation(ruleID string) ([]*model.CircuitBreakerRelation, error)

	// GetCircuitBreakerRelation 获取已标记熔断规则的绑定关系
	GetCircuitBreakerRelation(ruleID, ruleVersion string) ([]*model.CircuitBreakerRelation, error)

	// GetCircuitBreakerForCache 根据修改时间拉取增量熔断规则
	// 此方法用于 cache 增量更新,需要注意 mtime 应为数据库时间戳
	GetCircuitBreakerForCache(mtime time.Time, firstUpdate bool) ([]*model.ServiceWithCircuitBreaker, error)

	// ListMasterCircuitBreakers 获取master熔断规则
	ListMasterCircuitBreakers(filters map[string]string, offset uint32, limit uint32) (
		*model.CircuitBreakerDetail, error)

	// ListReleaseCircuitBreakers 获取已发布规则
	ListReleaseCircuitBreakers(filters map[string]string, offset, limit uint32) (
		*model.CircuitBreakerDetail, error)

	// GetCircuitBreakersByService 根据服务获取熔断规则
	GetCircuitBreakersByService(name string, namespace string) (*model.CircuitBreaker, 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)

	// GetConfigFileGroup 获取单个配置文件组
	GetConfigFileGroup(namespace, name string) (*model.ConfigFileGroup, error)

	// QueryConfigFileGroups 翻页查询配置文件组, name 为模糊匹配关键字
	QueryConfigFileGroups(namespace, name string, offset, limit uint32) (uint32, []*model.ConfigFileGroup, error)

	// DeleteConfigFileGroup 删除配置文件组
	DeleteConfigFileGroup(namespace, name string) error

	// UpdateConfigFileGroup 更新配置文件组
	UpdateConfigFileGroup(fileGroup *model.ConfigFileGroup) (*model.ConfigFileGroup, error)

	// FindConfigFileGroups 获取一组配置文件组信息
	FindConfigFileGroups(namespace string, names []string) ([]*model.ConfigFileGroup, error)

	// GetConfigFileGroupById 根据Id获取文件组信息
	GetConfigFileGroupById(id uint64) (*model.ConfigFileGroup, error)
}

ConfigFileGroupStore 配置文件组存储接口

type ConfigFileModuleStore

ConfigFileModuleStore 配置中心模块存储接口

type ConfigFileReleaseHistoryStore

type ConfigFileReleaseHistoryStore interface {

	// CreateConfigFileReleaseHistory 创建配置文件发布历史记录
	CreateConfigFileReleaseHistory(tx Tx, fileReleaseHistory *model.ConfigFileReleaseHistory) error

	// QueryConfigFileReleaseHistories 获取配置文件的发布历史记录
	QueryConfigFileReleaseHistories(namespace, group, fileName string, offset, limit uint32,
		endId uint64) (uint32, []*model.ConfigFileReleaseHistory, error)

	// GetLatestConfigFileReleaseHistory 获取配置文件最后一次发布
	GetLatestConfigFileReleaseHistory(namespace, group, fileName string) (*model.ConfigFileReleaseHistory, error)
}

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

type ConfigFileReleaseStore

type ConfigFileReleaseStore interface {

	// CreateConfigFileRelease 创建配置文件发布
	CreateConfigFileRelease(tx Tx, fileRelease *model.ConfigFileRelease) (*model.ConfigFileRelease, error)

	// UpdateConfigFileRelease 更新配置文件发布
	UpdateConfigFileRelease(tx Tx, fileRelease *model.ConfigFileRelease) (*model.ConfigFileRelease, error)

	// GetConfigFileRelease 获取配置文件发布内容,只获取 flag=0 的记录
	GetConfigFileRelease(tx Tx, namespace, group, fileName string) (*model.ConfigFileRelease, error)

	// GetConfigFileReleaseWithAllFlag 获取配置文件发布内容,返回所有 flag 的记录
	GetConfigFileReleaseWithAllFlag(tx Tx, namespace, group, fileName string) (*model.ConfigFileRelease, error)

	// DeleteConfigFileRelease 删除配置文件发布内容
	DeleteConfigFileRelease(tx Tx, namespace, group, fileName, deleteBy string) error

	// FindConfigFileReleaseByModifyTimeAfter 获取最近更新的配置文件发布
	// 此方法用于 cache 增量更新,需要注意 modifyTime 应为数据库时间戳
	FindConfigFileReleaseByModifyTimeAfter(modifyTime time.Time) ([]*model.ConfigFileRelease, error)
}

ConfigFileReleaseStore 配置文件发布存储接口

type ConfigFileStore

type ConfigFileStore interface {

	// CreateConfigFile 创建配置文件
	CreateConfigFile(tx Tx, file *model.ConfigFile) (*model.ConfigFile, error)

	// GetConfigFile 获取配置文件
	GetConfigFile(tx Tx, namespace, group, name string) (*model.ConfigFile, error)

	// QueryConfigFiles 翻页查询配置文件,group、name可为模糊匹配
	QueryConfigFiles(namespace, group, name string, offset, limit uint32) (uint32, []*model.ConfigFile, error)

	// QueryConfigFilesByGroup query config file group's files
	QueryConfigFilesByGroup(namespace, group string, offset, limit uint32) (uint32, []*model.ConfigFile, error)

	// UpdateConfigFile 更新配置文件
	UpdateConfigFile(tx Tx, file *model.ConfigFile) (*model.ConfigFile, error)

	// DeleteConfigFile 删除配置文件
	DeleteConfigFile(tx Tx, namespace, group, name string) error

	// CountByConfigFileGroup 获取一个配置文件组下的文件数量
	CountByConfigFileGroup(namespace, group string) (uint64, error)
}

ConfigFileStore 配置文件存储接口

type ConfigFileTagStore

type ConfigFileTagStore interface {

	// CreateConfigFileTag 创建配置文件标签
	CreateConfigFileTag(tx Tx, fileTag *model.ConfigFileTag) error

	// QueryConfigFileByTag 通过标签查询配置文件
	QueryConfigFileByTag(namespace, group, fileName string, tags ...string) ([]*model.ConfigFileTag, error)

	// QueryTagByConfigFile 查询配置文件标签
	QueryTagByConfigFile(namespace, group, fileName string) ([]*model.ConfigFileTag, error)

	// DeleteConfigFileTag 删除配置文件标签
	DeleteConfigFileTag(tx Tx, namespace, group, fileName, key, value string) error

	// DeleteTagByConfigFile 删除配置文件标签
	DeleteTagByConfigFile(tx Tx, namespace, group, fileName string) error
}

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 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
}

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

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)

	// 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(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
}

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 MaintainStore

type MaintainStore interface {

	// BatchCleanDeletedInstances batch clean soft deleted instances
	BatchCleanDeletedInstances(batchSize uint32) (uint32, error)
}

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

	// ListNamespaces Query all namespaces under Owner
	ListNamespaces(owner string) ([]*model.Namespace, 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
	// RateLimitStore 熔断规则接口
	CircuitBreakerStore
	// ToolStore 函数及工具接口
	ToolStore
	// UserStore 用户接口
	UserStore
	// GroupStore 用户组接口
	GroupStore
	// StrategyStore 鉴权策略接口
	StrategyStore
	// RoutingConfigStoreV2 路由策略 v2 接口
	RoutingConfigStoreV2
}

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, []*model.RateLimitRevision, 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 *v2.RoutingConfig) error
	// CreateRoutingConfigV2 新增一个路由配置
	CreateRoutingConfigV2(conf *v2.RoutingConfig) error
	// CreateRoutingConfigV2Tx 新增一个路由配置
	CreateRoutingConfigV2Tx(tx Tx, conf *v2.RoutingConfig) error
	// UpdateRoutingConfigV2 更新一个路由配置
	UpdateRoutingConfigV2(conf *v2.RoutingConfig) error
	// UpdateRoutingConfigV2Tx 更新一个路由配置
	UpdateRoutingConfigV2Tx(tx Tx, conf *v2.RoutingConfig) error
	// DeleteRoutingConfigV2 删除一个路由配置
	DeleteRoutingConfigV2(serviceID string) error
	// GetRoutingConfigsV2ForCache 通过mtime拉取增量的路由配置信息
	// 此方法用于 cache 增量更新,需要注意 mtime 应为数据库时间戳
	GetRoutingConfigsV2ForCache(mtime time.Time, firstUpdate bool) ([]*v2.RoutingConfig, error)
	// GetRoutingConfigV2WithID 根据服务ID拉取路由配置
	GetRoutingConfigV2WithID(id string) (*v2.RoutingConfig, error)
	// GetRoutingConfigV2WithIDTx 根据服务ID拉取路由配置
	GetRoutingConfigV2WithIDTx(tx Tx, id string) (*v2.RoutingConfig, error)
}

RoutingConfigStoreV2 路由配置表的存储接口

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

状态码定义

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)

	// 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

	// MaintainStore Maintain inteface
	MaintainStore
}

Store 通用存储接口

func GetStore

func GetStore() (Store, error)

GetStore 获取Store

func TestGetStore

func TestGetStore() (Store, error)

GetStore 获取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() (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{}
}

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