postgresql

package
v0.0.0-...-9453c44 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TickTime  = 2
	LeaseTime = 10
)
View Source
const (
	// SystemNamespace system namespace
	SystemNamespace = "Polaris"
	// STORENAME database storage name
	STORENAME = "postgresqlStore"
	// DefaultConnMaxLifetime default maximum connection lifetime
	DefaultConnMaxLifetime = 60 * 30 // 默认是30分钟

)
View Source
const (
	// IDAttribute is the name of the attribute that stores the ID of the object.
	IDAttribute string = "id"

	// NameAttribute will be used as the name of the attribute that stores the name of the object.
	NameAttribute string = "name"

	// FlagAttribute will be used as the name of the attribute that stores the flag of the object.
	FlagAttribute string = "flag"

	// GroupIDAttribute will be used as the name of the attribute that stores the group ID of the object.
	GroupIDAttribute string = "group_id"
)
View Source
const (
	OwnerAttribute string = "owner"
	And                   = " and"
)

Variables

View Source
var (
	RuleFilters map[string]string = map[string]string{
		"res_id":         "ar.res_id",
		"res_type":       "ar.res_type",
		"default":        "ag.default",
		"owner":          "ag.owner",
		"name":           "ag.name",
		"principal_id":   "ap.principal_id",
		"principal_type": "ap.principal_role",
	}

	RuleNeedLikeFilters map[string]struct{} = map[string]struct{}{
		"name": {},
	}
)
View Source
var (
	ErrTxIsNil = errors.New("tx is nil")
)

Functions

func BatchOperation

func BatchOperation(label string, data []interface{}, handler BatchHandler) error

BatchOperation 批量操作 @note 每次最多操作100个

func BatchQuery

func BatchQuery(label string, data []interface{}, handler BatchHandler) error

BatchQuery 批量查询数据的对外接口 每次最多查询200个

func ConvertSecond

func ConvertSecond(ctime time.Time) int64

ConvertSecond 转换指定时间的毫秒

func CurrDiffTimeSecond

func CurrDiffTimeSecond(beforeTime time.Time) float64

func GetCurrentSsTimestamp

func GetCurrentSsTimestamp() int64

func GetCurrentTimeFormat

func GetCurrentTimeFormat() string

GetCurrentTimeFormat 获取格式化时间 @param millTime:时间毫秒 @return 2006-01-02 15:04:05

func GetLocation

func GetLocation() *time.Location

func NewSqlDBTx

func NewSqlDBTx(delegateTx *BaseTx) store.Tx

func PlaceholdersNI

func PlaceholdersNI(size, indexSort int) (string, int)

PlaceholdersNI PlaceholdersN 构造多个占位符

func Retry

func Retry(label string, handle func() error)

Retry 重试主函数 最多重试20次,每次等待5ms*重试次数

func RetryTransaction

func RetryTransaction(label string, handle func() error) error

RetryTransaction 事务重试

func TimestampToInt64

func TimestampToInt64(timeStr string) int64

TimestampToInt64 时间字符串转换成int64

func UnixSecondToTime

func UnixSecondToTime(second int64) time.Time

UnixSecondToTime 秒级时间戳转time

Types

type BaseDB

type BaseDB struct {
	*sql.DB
	// contains filtered or unexported fields
}

BaseDB 对sql.DB的封装

func NewBaseDB

func NewBaseDB(cfg *dbConfig, parsePwd plugin.ParsePassword) (*BaseDB, error)

NewBaseDB 新建一个BaseDB

func (*BaseDB) Begin

func (b *BaseDB) Begin() (*BaseTx, error)

Begin 重写db.Begin

func (*BaseDB) Exec

func (b *BaseDB) Exec(query string, args ...interface{}) (sql.Result, error)

Exec 重写db.Exec函数 提供重试功能

func (*BaseDB) Query

func (b *BaseDB) Query(query string, args ...interface{}) (*sql.Rows, error)

Query 重写db.Query函数

func (*BaseDB) QueryRow

func (b *BaseDB) QueryRow(query string, args ...interface{}) *sql.Row

QueryRow 重写db.Query函数

type BaseTx

type BaseTx struct {
	*sql.Tx
}

BaseTx 对sql.Tx的封装

func (*BaseTx) Commit

func (b *BaseTx) Commit() error

Commit .

func (*BaseTx) Rollback

func (b *BaseTx) Rollback() error

Rollback .

type BatchHandler

type BatchHandler func(objects []interface{}) error

BatchHandler 批量查询数据的回调函数

type LeaderElectionStore

type LeaderElectionStore interface {
	CreateLeaderElection(key string) error
	// GetVersion get current version
	GetVersion(key string) (int64, error)
	// CompareAndSwapVersion cas version
	CompareAndSwapVersion(key string, curVersion int64, newVersion int64, leader string) (bool, error)
	// CheckMtimeExpired check mtime expired
	CheckMtimeExpired(key string, leaseTime int32) (string, bool, error)
	// ListLeaderElections list all leaderelection
	ListLeaderElections() ([]*model.LeaderElection, error)
}

type Order

type Order struct {
	Field    string
	Sequence string
}

Order 排序结构体

type Page

type Page struct {
	Offset uint32
	Limit  uint32
}

Page 分页结构体

type PostgresqlStore

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

PostgresqlStore 实现了Store接口

func (PostgresqlStore) ActiveConfigFileReleaseTx

func (cfr PostgresqlStore) ActiveConfigFileReleaseTx(tx store.Tx, release *model.ConfigFileRelease) error

ActiveConfigFileReleaseTx activates the specified config file release within a transaction.

func (PostgresqlStore) AddGroup

func (u PostgresqlStore) AddGroup(group *model.UserGroupDetail) error

AddGroup 创建一个用户组

func (PostgresqlStore) AddInstance

func (ins PostgresqlStore) AddInstance(instance *model.Instance) error

AddInstance 添加实例

func (PostgresqlStore) AddNamespace

func (ns PostgresqlStore) AddNamespace(namespace *model.Namespace) error

AddNamespace 添加命名空间

func (PostgresqlStore) AddService

func (ss PostgresqlStore) AddService(s *model.Service) error

AddService 增加服务

func (PostgresqlStore) AddServiceContractInterfaces

func (s PostgresqlStore) AddServiceContractInterfaces(contract *model.EnrichServiceContract) error

AddServiceContractInterfaces 创建服务契约API接口

func (PostgresqlStore) AddStrategy

func (s PostgresqlStore) AddStrategy(strategy *model.StrategyDetail) error

func (PostgresqlStore) AddUser

func (u PostgresqlStore) AddUser(user *model.User) error

AddUser 添加用户

func (PostgresqlStore) AppendServiceContractInterfaces

func (s PostgresqlStore) AppendServiceContractInterfaces(contract *model.EnrichServiceContract) error

AppendServiceContractInterfaces 追加服务契约API接口

func (PostgresqlStore) BatchAddClients

func (cs PostgresqlStore) BatchAddClients(clients []*model.Client) error

BatchAddClients 增加多个实例

func (PostgresqlStore) BatchAddInstances

func (ins PostgresqlStore) BatchAddInstances(instances []*model.Instance) error

BatchAddInstances 批量增加实例

func (PostgresqlStore) BatchAppendInstanceMetadata

func (ins PostgresqlStore) BatchAppendInstanceMetadata(requests []*store.InstanceMetadataRequest) error

BatchAppendInstanceMetadata 追加实例 metadata

func (PostgresqlStore) BatchCleanDeletedClients

func (m PostgresqlStore) BatchCleanDeletedClients(timeout time.Duration, batchSize uint32) (uint32, error)

BatchCleanDeletedClients 批量删除客户端

func (PostgresqlStore) BatchCleanDeletedInstances

func (m PostgresqlStore) BatchCleanDeletedInstances(timeout time.Duration, batchSize uint32) (uint32, error)

BatchCleanDeletedInstances 批量删除实例

func (PostgresqlStore) BatchDeleteClients

func (cs PostgresqlStore) BatchDeleteClients(ids []string) error

BatchDeleteClients 批量删除实例,flag=1

func (PostgresqlStore) BatchDeleteInstances

func (ins PostgresqlStore) BatchDeleteInstances(ids []interface{}) error

BatchDeleteInstances

func (PostgresqlStore) BatchGetInstanceIsolate

func (ins PostgresqlStore) BatchGetInstanceIsolate(ids map[string]bool) (map[string]bool, error)

BatchGetInstanceIsolate 检查实例是否存在

func (PostgresqlStore) BatchRemoveInstanceMetadata

func (ins PostgresqlStore) BatchRemoveInstanceMetadata(requests []*store.InstanceMetadataRequest) error

BatchRemoveInstanceMetadata 删除实例指定的 metadata

func (PostgresqlStore) BatchSetInstanceHealthStatus

func (ins PostgresqlStore) BatchSetInstanceHealthStatus(ids []interface{}, isolate int, revision string) error

BatchSetInstanceHealthStatus 批量设置健康状态

func (PostgresqlStore) BatchSetInstanceIsolate

func (ins PostgresqlStore) BatchSetInstanceIsolate(ids []interface{}, isolate int, revision string) error

BatchSetInstanceIsolate 批量设置实例隔离状态

func (PostgresqlStore) CleanConfigFileReleaseHistory

func (rh PostgresqlStore) CleanConfigFileReleaseHistory(endTime time.Time, limit uint64) error

CleanConfigFileReleaseHistory 清理配置发布历史

func (PostgresqlStore) CleanConfigFileReleasesTx

func (cfr PostgresqlStore) CleanConfigFileReleasesTx(tx store.Tx,
	namespace, group, fileName string) error

func (PostgresqlStore) CleanDeletedConfigFileRelease

func (cfr PostgresqlStore) CleanDeletedConfigFileRelease(endTime time.Time, limit uint64) error

CleanDeletedConfigFileRelease 清理配置发布历史

func (PostgresqlStore) CleanGrayResource

func (g PostgresqlStore) CleanGrayResource(tx store.Tx, data *model.GrayResource) error

func (PostgresqlStore) CleanInstance

func (ins PostgresqlStore) CleanInstance(instanceID string) error

CleanInstance 清理数据

func (PostgresqlStore) CountConfigFileEachGroup

func (cf PostgresqlStore) CountConfigFileEachGroup() (map[string]map[string]int64, error)

func (PostgresqlStore) CountConfigFiles

func (cf PostgresqlStore) CountConfigFiles(namespace, group string) (uint64, error)

func (PostgresqlStore) CountConfigGroups

func (fg PostgresqlStore) CountConfigGroups(namespace string) (uint64, error)

func (PostgresqlStore) CountConfigReleases

func (cfr PostgresqlStore) CountConfigReleases(namespace, group string, onlyActive bool) (uint64, error)

CountConfigReleases 获取一个配置文件组下的文件数量

func (PostgresqlStore) CreateCircuitBreakerRule

func (c PostgresqlStore) CreateCircuitBreakerRule(cbRule *model.CircuitBreakerRule) error

func (PostgresqlStore) CreateClient

func (cs PostgresqlStore) CreateClient(client *model.Client) error

CreateClient insert the client info

func (PostgresqlStore) CreateConfigFileGroup

func (fg PostgresqlStore) CreateConfigFileGroup(
	fileGroup *model.ConfigFileGroup) (*model.ConfigFileGroup, error)

CreateConfigFileGroup 创建配置文件组

func (PostgresqlStore) CreateConfigFileReleaseHistory

func (rh PostgresqlStore) CreateConfigFileReleaseHistory(history *model.ConfigFileReleaseHistory) error

CreateConfigFileReleaseHistory 创建配置文件发布历史记录

func (PostgresqlStore) CreateConfigFileReleaseTx

func (cfr PostgresqlStore) CreateConfigFileReleaseTx(tx store.Tx, data *model.ConfigFileRelease) error

CreateConfigFileReleaseTx 新建配置文件发布

func (PostgresqlStore) CreateConfigFileTemplate

func (cf PostgresqlStore) CreateConfigFileTemplate(
	template *model.ConfigFileTemplate) (*model.ConfigFileTemplate, error)

CreateConfigFileTemplate create config file template

func (PostgresqlStore) CreateConfigFileTx

func (cf PostgresqlStore) CreateConfigFileTx(tx store.Tx, file *model.ConfigFile) error

CreateConfigFileTx 创建配置文件

func (PostgresqlStore) CreateFaultDetectRule

func (f PostgresqlStore) CreateFaultDetectRule(fdRule *model.FaultDetectRule) error

CreateFaultDetectRule create fault detect rule

func (PostgresqlStore) CreateGrayResourceTx

func (g PostgresqlStore) CreateGrayResourceTx(tx store.Tx, data *model.GrayResource) error

CreateGrayResourceTx 创建灰度资源

func (PostgresqlStore) CreateRateLimit

func (rls PostgresqlStore) CreateRateLimit(limit *model.RateLimit) error

CreateRateLimit 新建限流规则

func (PostgresqlStore) CreateRoutingConfig

func (rs PostgresqlStore) CreateRoutingConfig(conf *model.RoutingConfig) error

CreateRoutingConfig 新建RoutingConfig

func (PostgresqlStore) CreateRoutingConfigV2

func (r PostgresqlStore) CreateRoutingConfigV2(conf *model.RouterConfig) error

CreateRoutingConfigV2 Add a new routing configuration

func (PostgresqlStore) CreateRoutingConfigV2Tx

func (r PostgresqlStore) CreateRoutingConfigV2Tx(tx store.Tx, conf *model.RouterConfig) error

func (PostgresqlStore) CreateServiceContract

func (s PostgresqlStore) CreateServiceContract(contract *model.ServiceContract) error

CreateServiceContract 创建服务契约

func (*PostgresqlStore) CreateTransaction

func (p *PostgresqlStore) CreateTransaction() (store.Transaction, error)

CreateTransaction 创建一个事务

func (PostgresqlStore) DeleteCircuitBreakerRule

func (c PostgresqlStore) DeleteCircuitBreakerRule(id string) error

DeleteCircuitBreakerRule 删除熔断规则

func (PostgresqlStore) DeleteConfigFileGroup

func (fg PostgresqlStore) DeleteConfigFileGroup(namespace, name string) error

DeleteConfigFileGroup 删除配置文件组

func (PostgresqlStore) DeleteConfigFileReleaseTx

func (cfr PostgresqlStore) DeleteConfigFileReleaseTx(tx store.Tx, data *model.ConfigFileReleaseKey) error

func (PostgresqlStore) DeleteConfigFileTx

func (cf PostgresqlStore) DeleteConfigFileTx(tx store.Tx, namespace, group, name string) error

func (PostgresqlStore) DeleteFaultDetectRule

func (f PostgresqlStore) DeleteFaultDetectRule(id string) error

DeleteFaultDetectRule delete fault detect rule

func (PostgresqlStore) DeleteGrayResource

func (g PostgresqlStore) DeleteGrayResource(tx store.Tx, data *model.GrayResource) error

DeleteGrayResource 删除灰度资源

func (PostgresqlStore) DeleteGroup

func (u PostgresqlStore) DeleteGroup(group *model.UserGroupDetail) error

DeleteGroup 删除用户组

func (PostgresqlStore) DeleteInstance

func (ins PostgresqlStore) DeleteInstance(instanceID string) error

DeleteInstance 删除一个实例,删除实例实际上是把flag置为1

func (PostgresqlStore) DeleteRateLimit

func (rls PostgresqlStore) DeleteRateLimit(limit *model.RateLimit) error

DeleteRateLimit 删除限流规则

func (PostgresqlStore) DeleteRoutingConfig

func (rs PostgresqlStore) DeleteRoutingConfig(serviceID string) error

DeleteRoutingConfig 删除

func (PostgresqlStore) DeleteRoutingConfigTx

func (rs PostgresqlStore) DeleteRoutingConfigTx(tx store.Tx, serviceID string) error

DeleteRoutingConfigTx 删除

func (PostgresqlStore) DeleteRoutingConfigV2

func (r PostgresqlStore) DeleteRoutingConfigV2(ruleID string) error

DeleteRoutingConfigV2 Delete a routing configuration

func (PostgresqlStore) DeleteService

func (ss PostgresqlStore) DeleteService(id, serviceName, namespaceName string) error

DeleteService 删除服务

func (PostgresqlStore) DeleteServiceAlias

func (ss PostgresqlStore) DeleteServiceAlias(name string, namespace string) error

DeleteServiceAlias 删除服务别名

func (PostgresqlStore) DeleteServiceContract

func (s PostgresqlStore) DeleteServiceContract(contract *model.ServiceContract) error

DeleteServiceContract 删除服务契约 删除该版本的全部数据

func (PostgresqlStore) DeleteServiceContractInterfaces

func (s PostgresqlStore) DeleteServiceContractInterfaces(contract *model.EnrichServiceContract) error

DeleteServiceContractInterfaces 删除服务契约API接口

func (PostgresqlStore) DeleteStrategy

func (s PostgresqlStore) DeleteStrategy(id string) error

func (PostgresqlStore) DeleteUser

func (u PostgresqlStore) DeleteUser(user *model.User) error

DeleteUser delete user by user id

func (*PostgresqlStore) Destroy

func (p *PostgresqlStore) Destroy() error

Destroy 退出函数

func (PostgresqlStore) EnableCircuitBreakerRule

func (c PostgresqlStore) EnableCircuitBreakerRule(cbRule *model.CircuitBreakerRule) error

EnableCircuitBreakerRule enable circuitbreaker rule

func (PostgresqlStore) EnableRateLimit

func (rls PostgresqlStore) EnableRateLimit(limit *model.RateLimit) error

EnableRateLimit 启用限流规则

func (PostgresqlStore) EnableRouting

func (r PostgresqlStore) EnableRouting(conf *model.RouterConfig) error

EnableRouting Enable current limit rules

func (PostgresqlStore) GenNextL5Sid

func (l5 PostgresqlStore) GenNextL5Sid(layoutID uint32) (string, error)

GenNextL5Sid 获取下一个sid

func (PostgresqlStore) GetCircuitBreakerRules

func (c PostgresqlStore) GetCircuitBreakerRules(
	filter map[string]string, offset uint32, limit uint32) (uint32, []*model.CircuitBreakerRule, error)

func (PostgresqlStore) GetCircuitBreakerRulesForCache

func (c PostgresqlStore) GetCircuitBreakerRulesForCache(
	mtime time.Time, firstUpdate bool) ([]*model.CircuitBreakerRule, error)

GetCircuitBreakerRulesForCache list circuitbreaker rules by query

func (PostgresqlStore) GetClientStat

func (cs PostgresqlStore) GetClientStat(clientID string) ([]*model.ClientStatStore, error)

func (PostgresqlStore) GetConfigFile

func (cf PostgresqlStore) GetConfigFile(namespace, group, name string) (*model.ConfigFile, error)

GetConfigFile 获取配置文件

func (PostgresqlStore) GetConfigFileActiveRelease

func (cfr PostgresqlStore) GetConfigFileActiveRelease(file *model.ConfigFileKey) (*model.ConfigFileRelease, error)

func (PostgresqlStore) GetConfigFileActiveReleaseTx

func (cfr PostgresqlStore) GetConfigFileActiveReleaseTx(tx store.Tx,
	file *model.ConfigFileKey) (*model.ConfigFileRelease, error)

GetConfigFileActiveReleaseTx retrieves the active release of a configuration file within a transaction.

func (PostgresqlStore) GetConfigFileBetaReleaseTx

func (cfr PostgresqlStore) GetConfigFileBetaReleaseTx(tx store.Tx,
	file *model.ConfigFileKey) (*model.ConfigFileRelease, error)

GetConfigFileBetaReleaseTx retrieves the beta release of a configuration file within a transaction.

func (PostgresqlStore) GetConfigFileGroup

func (fg PostgresqlStore) GetConfigFileGroup(namespace, name string) (*model.ConfigFileGroup, error)

GetConfigFileGroup 获取配置文件组

func (PostgresqlStore) GetConfigFileRelease

func (cfr PostgresqlStore) GetConfigFileRelease(req *model.ConfigFileReleaseKey) (*model.ConfigFileRelease, error)

GetConfigFileRelease 获取配置文件发布,只返回 flag=0 的记录

func (PostgresqlStore) GetConfigFileReleaseTx

func (cfr PostgresqlStore) GetConfigFileReleaseTx(tx store.Tx,
	req *model.ConfigFileReleaseKey) (*model.ConfigFileRelease, error)

GetConfigFileReleaseTx 在已开启的事务中获取配置文件发布内容,只获取 flag=0 的记录

func (PostgresqlStore) GetConfigFileTemplate

func (cf PostgresqlStore) GetConfigFileTemplate(name string) (*model.ConfigFileTemplate, error)

GetConfigFileTemplate get config file template by name

func (PostgresqlStore) GetConfigFileTx

func (cf PostgresqlStore) GetConfigFileTx(tx store.Tx,
	namespace, group, name string) (*model.ConfigFile, error)

func (PostgresqlStore) GetDefaultStrategyDetailByPrincipal

func (s PostgresqlStore) GetDefaultStrategyDetailByPrincipal(principalId string,
	principalType model.PrincipalType) (*model.StrategyDetail, error)

GetDefaultStrategyDetailByPrincipal 获取默认策略

func (PostgresqlStore) GetExpandInstances

func (ins PostgresqlStore) GetExpandInstances(filter, metaFilter map[string]string, offset uint32,
	limit uint32) (uint32, []*model.Instance, error)

GetExpandInstances 根据过滤条件查看对应服务实例及数目

func (PostgresqlStore) GetExtendRateLimits

func (rls PostgresqlStore) GetExtendRateLimits(
	filter map[string]string, offset uint32, limit uint32) (uint32, []*model.ExtendRateLimit, error)

GetExtendRateLimits 根据过滤条件获取限流规则及数目

func (PostgresqlStore) GetFaultDetectRules

func (f PostgresqlStore) GetFaultDetectRules(
	filter map[string]string, offset uint32, limit uint32) (uint32, []*model.FaultDetectRule, error)

GetFaultDetectRules get all fault detect rules by query and limit

func (PostgresqlStore) GetFaultDetectRulesForCache

func (f PostgresqlStore) GetFaultDetectRulesForCache(
	mtime time.Time, firstUpdate bool) ([]*model.FaultDetectRule, error)

GetFaultDetectRulesForCache get increment circuitbreaker rules

func (PostgresqlStore) GetGroup

func (u PostgresqlStore) GetGroup(groupId string) (*model.UserGroupDetail, error)

GetGroup 根据用户组ID获取用户组

func (PostgresqlStore) GetGroupByName

func (u PostgresqlStore) GetGroupByName(name, owner string) (*model.UserGroup, error)

GetGroupByName 根据 owner、name 获取用户组

func (PostgresqlStore) GetGroups

func (u PostgresqlStore) GetGroups(filters map[string]string, offset uint32, limit uint32) (uint32,
	[]*model.UserGroup, error)

GetGroups 根据不同的请求情况进行不同的用户组列表查询

func (PostgresqlStore) GetGroupsForCache

func (u PostgresqlStore) GetGroupsForCache(mtime time.Time, firstUpdate bool) ([]*model.UserGroupDetail, error)

GetGroupsForCache .

func (PostgresqlStore) GetInstance

func (ins PostgresqlStore) GetInstance(instanceID string) (*model.Instance, error)

GetInstance 获取单个实例详情,只返回有效的数据

func (PostgresqlStore) GetInstanceMeta

func (ins PostgresqlStore) GetInstanceMeta(instanceID string) (map[string]string, error)

GetInstanceMeta 根据实例ID获取实例的metadata

func (PostgresqlStore) GetInstancesBrief

func (ins PostgresqlStore) GetInstancesBrief(ids map[string]bool) (map[string]*model.Instance, error)

GetInstancesBrief 批量获取实例的serviceID

func (PostgresqlStore) GetInstancesCount

func (ins PostgresqlStore) GetInstancesCount() (uint32, error)

GetInstancesCount 获取有效的实例总数

func (PostgresqlStore) GetInstancesCountTx

func (ins PostgresqlStore) GetInstancesCountTx(tx store.Tx) (uint32, error)

GetInstancesCountTx .

func (PostgresqlStore) GetInstancesMainByService

func (ins PostgresqlStore) GetInstancesMainByService(serviceID, host string) ([]*model.Instance, error)

GetInstancesMainByService 根据服务和host获取实例 @note 不包括metadata

func (PostgresqlStore) GetL5Extend

func (l5 PostgresqlStore) GetL5Extend(serviceID string) (map[string]interface{}, error)

GetL5Extend 获取L5扩展数据

func (PostgresqlStore) GetMoreClients

func (cs PostgresqlStore) GetMoreClients(mtime time.Time, firstUpdate bool) (map[string]*model.Client, error)

GetMoreClients 根据mtime获取增量clients,返回所有store的变更信息

func (PostgresqlStore) GetMoreConfigGroup

func (fg PostgresqlStore) GetMoreConfigGroup(firstUpdate bool, mtime time.Time) ([]*model.ConfigFileGroup, error)

func (PostgresqlStore) GetMoreGrayResouces

func (g PostgresqlStore) GetMoreGrayResouces(firstUpdate bool,
	modifyTime time.Time) ([]*model.GrayResource, error)

GetMoreGrayResouces 获取最近更新的灰度资源, 此方法用于 cache 增量更新,需要注意 modifyTime 应为数据库时间戳

func (PostgresqlStore) GetMoreInstances

func (ins PostgresqlStore) GetMoreInstances(tx store.Tx, mtime time.Time, firstUpdate, needMeta bool,
	serviceID []string) (map[string]*model.Instance, error)

GetMoreInstances 根据mtime获取增量修改数据 这里会返回所有的数据的,包括valid=false的数据 对于首次拉取,firstUpdate=true,只会拉取flag!=1的数据

func (PostgresqlStore) GetMoreL5Extend

func (l5 PostgresqlStore) GetMoreL5Extend(mtime time.Time) (map[string]map[string]interface{}, error)

GetMoreL5Extend 获取更多的增量数据

func (PostgresqlStore) GetMoreL5IPConfigs

func (l5 PostgresqlStore) GetMoreL5IPConfigs(flow uint32) ([]*model.IPConfig, error)

GetMoreL5IPConfigs 获取更多的L5 IPConfig信息

func (PostgresqlStore) GetMoreL5Policies

func (l5 PostgresqlStore) GetMoreL5Policies(flow uint32) ([]*model.Policy, error)

GetMoreL5Policies 获取更多的L5 Policy信息

func (PostgresqlStore) GetMoreL5Routes

func (l5 PostgresqlStore) GetMoreL5Routes(flow uint32) ([]*model.Route, error)

GetMoreL5Routes 获取更多的L5 Route信息

func (PostgresqlStore) GetMoreL5Sections

func (l5 PostgresqlStore) GetMoreL5Sections(flow uint32) ([]*model.Section, error)

GetMoreL5Sections 获取更多的L5 Section信息

func (PostgresqlStore) GetMoreNamespaces

func (ns PostgresqlStore) GetMoreNamespaces(mtime time.Time) ([]*model.Namespace, error)

GetMoreNamespaces 根据mtime获取命名空间

func (PostgresqlStore) GetMoreReleaseFile

func (cfr PostgresqlStore) GetMoreReleaseFile(firstUpdate bool, modifyTime time.Time) ([]*model.ConfigFileRelease, error)

GetMoreReleaseFile 获取最近更新的配置文件发布, 此方法用于 cache 增量更新,需要注意 modifyTime 应为数据库时间戳

func (PostgresqlStore) GetMoreServiceContracts

func (s PostgresqlStore) GetMoreServiceContracts(firstUpdate bool, mtime time.Time) ([]*model.EnrichServiceContract, error)

GetMoreServiceContracts 查询服务契约数据

func (PostgresqlStore) GetMoreServices

func (ss PostgresqlStore) GetMoreServices(mtime time.Time, firstUpdate, disableBusiness, needMeta bool) (
	map[string]*model.Service, error)

GetMoreServices 根据modify_time获取增量数据

func (PostgresqlStore) GetNamespace

func (ns PostgresqlStore) GetNamespace(name string) (*model.Namespace, error)

GetNamespace 根据名字获取命名空间详情,只返回有效的

func (PostgresqlStore) GetNamespaces

func (ns PostgresqlStore) GetNamespaces(filter map[string][]string, offset,
	limit int) ([]*model.Namespace, uint32, error)

GetNamespaces 根据过滤条件查询命名空间及数目

func (PostgresqlStore) GetRateLimitWithID

func (rls PostgresqlStore) GetRateLimitWithID(id string) (*model.RateLimit, error)

GetRateLimitWithID 根据限流规则ID获取限流规则

func (PostgresqlStore) GetRateLimitsForCache

func (rls PostgresqlStore) GetRateLimitsForCache(mtime time.Time,
	firstUpdate bool) ([]*model.RateLimit, error)

GetRateLimitsForCache 根据修改时间拉取增量限流规则及最新版本号

func (PostgresqlStore) GetRoutingConfigV2WithID

func (r PostgresqlStore) GetRoutingConfigV2WithID(ruleID string) (*model.RouterConfig, error)

GetRoutingConfigV2WithID Pull the routing configuration according to the rules ID

func (PostgresqlStore) GetRoutingConfigV2WithIDTx

func (r PostgresqlStore) GetRoutingConfigV2WithIDTx(tx store.Tx, ruleID string) (*model.RouterConfig, error)

GetRoutingConfigV2WithIDTx Pull the routing configuration according to the rules ID

func (PostgresqlStore) GetRoutingConfigWithID

func (rs PostgresqlStore) GetRoutingConfigWithID(id string) (*model.RoutingConfig, error)

GetRoutingConfigWithID 根据服务ID获取对应的配置

func (PostgresqlStore) GetRoutingConfigWithService

func (rs PostgresqlStore) GetRoutingConfigWithService(name string, namespace string) (*model.RoutingConfig, error)

GetRoutingConfigWithService 根据服务名+namespace获取对应的配置

func (PostgresqlStore) GetRoutingConfigs

func (rs PostgresqlStore) GetRoutingConfigs(filter map[string]string,
	offset uint32, limit uint32) (uint32, []*model.ExtendRoutingConfig, error)

GetRoutingConfigs 获取路由配置列表

func (PostgresqlStore) GetRoutingConfigsForCache

func (rs PostgresqlStore) GetRoutingConfigsForCache(mtime time.Time,
	firstUpdate bool) ([]*model.RoutingConfig, error)

GetRoutingConfigsForCache 缓存增量拉取

func (PostgresqlStore) GetRoutingConfigsV2ForCache

func (r PostgresqlStore) GetRoutingConfigsV2ForCache(
	mtime time.Time, firstUpdate bool) ([]*model.RouterConfig, error)

GetRoutingConfigsV2ForCache Pull the incremental routing configuration information through mtime

func (PostgresqlStore) GetService

func (ss PostgresqlStore) GetService(name string, namespace string) (*model.Service, error)

GetService 获取服务详情,只返回有效的数据

func (PostgresqlStore) GetServiceAliases

func (ss PostgresqlStore) GetServiceAliases(filter map[string]string, offset uint32, limit uint32) (uint32,
	[]*model.ServiceAlias, error)

GetServiceAliases 获取服务别名列表

func (PostgresqlStore) GetServiceByID

func (ss PostgresqlStore) GetServiceByID(id string) (*model.Service, error)

GetServiceByID 根据服务ID查询服务详情

func (PostgresqlStore) GetServiceContract

func (s PostgresqlStore) GetServiceContract(id string) (data *model.EnrichServiceContract, err error)

GetServiceContract 通过ID查询服务契约数据

func (PostgresqlStore) GetServices

func (ss PostgresqlStore) GetServices(serviceFilters, serviceMetas map[string]string, instanceFilters *store.InstanceArgs,
	offset, limit uint32) (uint32, []*model.Service, error)

GetServices 根据相关条件查询对应服务及数目,不包括别名

func (PostgresqlStore) GetServicesBatch

func (ss PostgresqlStore) GetServicesBatch(services []*model.Service) ([]*model.Service, error)

GetServicesBatch 查询多个服务的id

func (PostgresqlStore) GetServicesCount

func (ss PostgresqlStore) GetServicesCount() (uint32, error)

GetServicesCount 获取所有服务总数

func (PostgresqlStore) GetSourceServiceToken

func (ss PostgresqlStore) GetSourceServiceToken(name string, namespace string) (*model.Service, error)

GetSourceServiceToken 获取只获取服务token 返回服务ID,服务token

func (PostgresqlStore) GetStrategies

func (s PostgresqlStore) GetStrategies(filters map[string]string, offset uint32, limit uint32) (uint32,
	[]*model.StrategyDetail, error)

GetStrategies 获取策略列表

func (PostgresqlStore) GetStrategyDetail

func (s PostgresqlStore) GetStrategyDetail(id string) (*model.StrategyDetail, error)

GetStrategyDetail 获取策略详情

func (PostgresqlStore) GetStrategyDetailsForCache

func (s PostgresqlStore) GetStrategyDetailsForCache(mtime time.Time,
	firstUpdate bool) ([]*model.StrategyDetail, error)

func (PostgresqlStore) GetStrategyResources

func (s PostgresqlStore) GetStrategyResources(principalId string,
	principalRole model.PrincipalType) ([]model.StrategyResource, error)

GetStrategyResources 获取对应 principal 能操作的所有资源

func (PostgresqlStore) GetSubCount

func (u PostgresqlStore) GetSubCount(user *model.User) (uint32, error)

GetSubCount get user's sub count

func (PostgresqlStore) GetSystemServices

func (ss PostgresqlStore) GetSystemServices() ([]*model.Service, error)

GetSystemServices 获取系统服务

func (PostgresqlStore) GetUnHealthyInstances

func (m PostgresqlStore) GetUnHealthyInstances(timeout time.Duration, limit uint32) ([]string, error)

GetUnHealthyInstances 获取实例

func (PostgresqlStore) GetUnixSecond

func (t PostgresqlStore) GetUnixSecond(maxWait time.Duration) (int64, error)

GetUnixSecond 获取当前时间,单位秒

func (PostgresqlStore) GetUser

func (u PostgresqlStore) GetUser(id string) (*model.User, error)

GetUser get user by user id

func (PostgresqlStore) GetUserByIds

func (u PostgresqlStore) GetUserByIds(ids []string) ([]*model.User, error)

GetUserByIds Get user list data according to user ID

func (PostgresqlStore) GetUserByName

func (u PostgresqlStore) GetUserByName(name, ownerId string) (*model.User, error)

GetUserByName 根据用户名、owner 获取用户

func (PostgresqlStore) GetUsers

func (u PostgresqlStore) GetUsers(filters map[string]string, offset uint32, limit uint32) (uint32,
	[]*model.User, error)

GetUsers Query user list information Case 1. From the user's perspective, normal query conditions Case 2. From the perspective of the user group, query is the list of users involved under a user group.

func (PostgresqlStore) GetUsersForCache

func (u PostgresqlStore) GetUsersForCache(mtime time.Time, firstUpdate bool) ([]*model.User, error)

GetUsersForCache Get user information, mainly for cache

func (PostgresqlStore) HasCircuitBreakerRule

func (c PostgresqlStore) HasCircuitBreakerRule(id string) (bool, error)

HasCircuitBreakerRule check circuitbreaker rule exists

func (PostgresqlStore) HasCircuitBreakerRuleByName

func (c PostgresqlStore) HasCircuitBreakerRuleByName(name string, namespace string) (bool, error)

HasCircuitBreakerRuleByName check circuitbreaker rule exists by name

func (PostgresqlStore) HasCircuitBreakerRuleByNameExcludeId

func (c PostgresqlStore) HasCircuitBreakerRuleByNameExcludeId(
	name string, namespace string, id string) (bool, error)

HasCircuitBreakerRuleByNameExcludeId check circuitbreaker rule exists by name exclude id

func (PostgresqlStore) HasFaultDetectRule

func (f PostgresqlStore) HasFaultDetectRule(id string) (bool, error)

HasFaultDetectRule check fault detect rule exists

func (PostgresqlStore) HasFaultDetectRuleByName

func (f PostgresqlStore) HasFaultDetectRuleByName(name string, namespace string) (bool, error)

HasFaultDetectRuleByName check fault detect rule exists by name

func (PostgresqlStore) HasFaultDetectRuleByNameExcludeId

func (f PostgresqlStore) HasFaultDetectRuleByNameExcludeId(
	name string, namespace string, id string) (bool, error)

HasFaultDetectRuleByNameExcludeId check fault detect rule exists by name not this id

func (PostgresqlStore) InactiveConfigFileReleaseTx

func (cfr PostgresqlStore) InactiveConfigFileReleaseTx(tx store.Tx, release *model.ConfigFileRelease) error

InactiveConfigFileReleaseTx deactivates the specified config file release within a transaction.

func (*PostgresqlStore) Initialize

func (p *PostgresqlStore) Initialize(conf *store.Config) error

Initialize 初始化函数

func (PostgresqlStore) IsLeader

func (m PostgresqlStore) IsLeader(key string) bool

IsLeader 校验是leader

func (PostgresqlStore) ListLeaderElections

func (m PostgresqlStore) ListLeaderElections() ([]*model.LeaderElection, error)

ListLeaderElections leader选举列表

func (PostgresqlStore) LockConfigFile

func (cf PostgresqlStore) LockConfigFile(tx store.Tx, file *model.ConfigFileKey) (*model.ConfigFile, error)

LockConfigFile 加锁配置文件

func (PostgresqlStore) LooseAddStrategyResources

func (s PostgresqlStore) LooseAddStrategyResources(resources []model.StrategyResource) error

LooseAddStrategyResources loose add strategy resources

func (*PostgresqlStore) Name

func (p *PostgresqlStore) Name() string

Name 实现Name函数

func (PostgresqlStore) QueryAllConfigFileTemplates

func (cf PostgresqlStore) QueryAllConfigFileTemplates() ([]*model.ConfigFileTemplate, error)

QueryAllConfigFileTemplates query all config file templates

func (PostgresqlStore) QueryConfigFileReleaseHistories

func (rh PostgresqlStore) QueryConfigFileReleaseHistories(filter map[string]string,
	offset, limit uint32) (uint32, []*model.ConfigFileReleaseHistory, error)

QueryConfigFileReleaseHistories 获取配置文件的发布历史记录

func (PostgresqlStore) QueryConfigFiles

func (cf PostgresqlStore) QueryConfigFiles(filter map[string]string, offset, limit uint32) (uint32, []*model.ConfigFile, error)

QueryConfigFiles 翻页查询配置文件,group、name可为模糊匹配

func (PostgresqlStore) ReleaseLeaderElection

func (m PostgresqlStore) ReleaseLeaderElection(key string) error

ReleaseLeaderElection 释放选举锁

func (PostgresqlStore) RemoveStrategyResources

func (s PostgresqlStore) RemoveStrategyResources(resources []model.StrategyResource) error

RemoveStrategyResources 删除策略的资源

func (PostgresqlStore) SetInstanceHealthStatus

func (ins PostgresqlStore) SetInstanceHealthStatus(instanceID string, flag int, revision string) error

SetInstanceHealthStatus 设置实例健康状态

func (PostgresqlStore) SetL5Extend

func (l5 PostgresqlStore) SetL5Extend(serviceID string, meta map[string]interface{}) (map[string]interface{}, error)

SetL5Extend 保存L5扩展数据

func (PostgresqlStore) StartLeaderElection

func (m PostgresqlStore) StartLeaderElection(key string) error

StartLeaderElection 开始leader选举

func (*PostgresqlStore) StartReadTx

func (p *PostgresqlStore) StartReadTx() (store.Tx, error)

func (*PostgresqlStore) StartTx

func (p *PostgresqlStore) StartTx() (store.Tx, error)

func (PostgresqlStore) StopLeaderElections

func (m PostgresqlStore) StopLeaderElections()

StopLeaderElections 停止leader选举

func (PostgresqlStore) UpdateCircuitBreakerRule

func (c PostgresqlStore) UpdateCircuitBreakerRule(cbRule *model.CircuitBreakerRule) error

UpdateCircuitBreakerRule 更新熔断规则

func (PostgresqlStore) UpdateClient

func (cs PostgresqlStore) UpdateClient(client *model.Client) error

UpdateClient update the client info

func (PostgresqlStore) UpdateConfigFileGroup

func (fg PostgresqlStore) UpdateConfigFileGroup(fileGroup *model.ConfigFileGroup) error

UpdateConfigFileGroup 更新配置文件组信息

func (PostgresqlStore) UpdateConfigFileTx

func (cf PostgresqlStore) UpdateConfigFileTx(tx store.Tx, file *model.ConfigFile) error

UpdateConfigFileTx 更新配置文件

func (PostgresqlStore) UpdateFaultDetectRule

func (f PostgresqlStore) UpdateFaultDetectRule(fdRule *model.FaultDetectRule) error

UpdateFaultDetectRule update fault detect rule

func (PostgresqlStore) UpdateGroup

func (u PostgresqlStore) UpdateGroup(group *model.ModifyUserGroup) error

UpdateGroup 更新用户组

func (PostgresqlStore) UpdateInstance

func (ins PostgresqlStore) UpdateInstance(instance *model.Instance) error

UpdateInstance 更新实例

func (PostgresqlStore) UpdateNamespace

func (ns PostgresqlStore) UpdateNamespace(namespace *model.Namespace) error

UpdateNamespace 更新命名空间,目前只更新owner

func (PostgresqlStore) UpdateNamespaceToken

func (ns PostgresqlStore) UpdateNamespaceToken(name string, token string) error

UpdateNamespaceToken 更新命名空间token

func (PostgresqlStore) UpdateRateLimit

func (rls PostgresqlStore) UpdateRateLimit(limit *model.RateLimit) error

UpdateRateLimit 更新限流规则

func (PostgresqlStore) UpdateRoutingConfig

func (rs PostgresqlStore) UpdateRoutingConfig(conf *model.RoutingConfig) error

UpdateRoutingConfig 更新

func (PostgresqlStore) UpdateRoutingConfigV2

func (r PostgresqlStore) UpdateRoutingConfigV2(conf *model.RouterConfig) error

UpdateRoutingConfigV2 Update a routing configuration

func (PostgresqlStore) UpdateRoutingConfigV2Tx

func (r PostgresqlStore) UpdateRoutingConfigV2Tx(tx store.Tx, conf *model.RouterConfig) error

func (PostgresqlStore) UpdateService

func (ss PostgresqlStore) UpdateService(service *model.Service, needUpdateOwner bool) error

UpdateService 更新完整的服务信息

func (PostgresqlStore) UpdateServiceAlias

func (ss PostgresqlStore) UpdateServiceAlias(alias *model.Service, needUpdateOwner bool) error

UpdateServiceAlias 更新服务别名

func (PostgresqlStore) UpdateServiceContract

func (s PostgresqlStore) UpdateServiceContract(contract *model.ServiceContract) error

UpdateServiceContract 更新服务契约信息

func (PostgresqlStore) UpdateServiceToken

func (ss PostgresqlStore) UpdateServiceToken(id string, token string, revision string) error

UpdateServiceToken 更新服务token

func (PostgresqlStore) UpdateStrategy

func (s PostgresqlStore) UpdateStrategy(strategy *model.ModifyStrategyDetail) error

UpdateStrategy 更新鉴权规则

func (PostgresqlStore) UpdateUser

func (u PostgresqlStore) UpdateUser(user *model.User) error

UpdateUser 更新用户信息

type QueryHandler

type QueryHandler func(query string, args ...interface{}) (*sql.Rows, error)

QueryHandler is the interface that wraps the basic Query method.

type Tx

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

func (*Tx) Commit

func (t *Tx) Commit() error

func (*Tx) CreateReadView

func (t *Tx) CreateReadView() error

func (*Tx) GetDelegateTx

func (t *Tx) GetDelegateTx() interface{}

func (*Tx) Rollback

func (t *Tx) Rollback() error

Jump to

Keyboard shortcuts

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