constancy

package
v2.15.4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const DbaasOperatorModeEnvVar = "DBAAS_OPERATOR_ENABLED"

DbaasOperatorModeEnvVar names the flag the Helm chart sets to "true" when the cluster serves the DBaaS Operator CRDs. core-bootstrap reads the same variable with the same meaning.

Variables

View Source
var BunMigrationsTable = "bun_migrations"

check name of tables of migrations and locks in migrator.NewMigrator

Functions

func DbaasOperatorModeEnabled added in v2.15.0

func DbaasOperatorModeEnabled() bool

DbaasOperatorModeEnabled reports whether the DBaaS Operator provisions this service's database. It parses the flag the way core-bootstrap does: only "true", in any letter case, enables it.

Types

type BatchStorage

type BatchStorage interface {
	Insert([]interface{}) error
	Update([]interface{}) error
	Delete([]interface{}) error
}

type BatchTransactionManager

type BatchTransactionManager interface {
	WithTxBatch(func(tx BatchStorage) error) error
}

type Configurator

type Configurator interface {
	GetDBName() string
	GetDBUserName() string
	GetDBPassword() string
	GetDBTls() string
	GetDBHost() string
	GetDBPort() string
	GetDBRole() string
}

type DbaasAggregatorLogicalDbProvider

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

func NewDbaasAggregatorLogicalDbProvider

func NewDbaasAggregatorLogicalDbProvider(cfg Configurator) *DbaasAggregatorLogicalDbProvider

func (*DbaasAggregatorLogicalDbProvider) GetConnection

func (p *DbaasAggregatorLogicalDbProvider) GetConnection(dbType string, classifier map[string]interface{}, params rest.BaseDbParams) (map[string]interface{}, error)

func (*DbaasAggregatorLogicalDbProvider) GetOrCreateDb

func (p *DbaasAggregatorLogicalDbProvider) GetOrCreateDb(dbType string, classifier map[string]interface{}, params rest.BaseDbParams) (*model.LogicalDb, error)

type Flusher

type Flusher struct {
	BatchTm         BatchTransactionManager
	PodStateManager PodStateManager
}

func (*Flusher) CheckCurrentPodState

func (f *Flusher) CheckCurrentPodState() error

func (*Flusher) Flush

func (f *Flusher) Flush(changes []memdb.Change) error

type PGConnWrapper

type PGConnWrapper interface {
	Model(conn *bun.SelectQuery, model interface{}) *bun.SelectQuery
	Begin(conn *bun.Conn) (*bun.Tx, error)
	Close(conn *bun.Conn) error
}

PGConnWrapper pg.Conn

type PGConnWrapperImpl

type PGConnWrapperImpl struct {
}

func (*PGConnWrapperImpl) Begin

func (db *PGConnWrapperImpl) Begin(conn *bun.Conn) (*bun.Tx, error)

func (*PGConnWrapperImpl) Close

func (db *PGConnWrapperImpl) Close(conn *bun.Conn) error

func (*PGConnWrapperImpl) Model

func (db *PGConnWrapperImpl) Model(conn *bun.SelectQuery, model interface{}) *bun.SelectQuery

type PGQueryWrapper

type PGQueryWrapper interface {
	Select(conn *bun.Conn) *bun.SelectQuery
	Where(query *bun.SelectQuery, condition string, params interface{}) *bun.SelectQuery
	Scan(query *bun.SelectQuery) error
}

PGQueryWrapper pg.Query

type PGQueryWrapperImpl

type PGQueryWrapperImpl struct {
}

func (*PGQueryWrapperImpl) Scan

func (q *PGQueryWrapperImpl) Scan(query *bun.SelectQuery) error

func (*PGQueryWrapperImpl) Select

func (q *PGQueryWrapperImpl) Select(conn *bun.Conn) *bun.SelectQuery

func (*PGQueryWrapperImpl) Where

func (q *PGQueryWrapperImpl) Where(query *bun.SelectQuery, condition string, params interface{}) *bun.SelectQuery

type PGTxWrapper

type PGTxWrapper interface {
	Rollback(*bun.Tx) error
	Commit(*bun.Tx) error
}

PGTxWrapper pg.Tx

type PGTxWrapperImpl

type PGTxWrapperImpl struct {
}

func (*PGTxWrapperImpl) Commit

func (db *PGTxWrapperImpl) Commit(tx *bun.Tx) error

func (*PGTxWrapperImpl) Rollback

func (db *PGTxWrapperImpl) Rollback(tx *bun.Tx) error

type PgBatchStorage

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

func (*PgBatchStorage) Delete

func (s *PgBatchStorage) Delete(entities []interface{}) error

func (*PgBatchStorage) Insert

func (s *PgBatchStorage) Insert(entities []interface{}) error

func (*PgBatchStorage) Update

func (s *PgBatchStorage) Update(entities []interface{}) error

type PodStateManager

type PodStateManager interface {
	IsCurrentPodDefinedAsMaster() (bool, error)
}

type PodStateManagerImpl

type PodStateManagerImpl struct {
	Storage Storage
}

func (*PodStateManagerImpl) IsCurrentPodDefinedAsMaster

func (podStateManager *PodStateManagerImpl) IsCurrentPodDefinedAsMaster() (bool, error)

type PostgresStorageConfigurator

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

func NewPostgresStorageConfigurator

func NewPostgresStorageConfigurator() (*PostgresStorageConfigurator, error)

func (PostgresStorageConfigurator) GetDBHost

func (p PostgresStorageConfigurator) GetDBHost() string

func (PostgresStorageConfigurator) GetDBName

func (p PostgresStorageConfigurator) GetDBName() string

func (PostgresStorageConfigurator) GetDBPassword

func (p PostgresStorageConfigurator) GetDBPassword() string

func (PostgresStorageConfigurator) GetDBPort

func (p PostgresStorageConfigurator) GetDBPort() string

func (PostgresStorageConfigurator) GetDBRole

func (p PostgresStorageConfigurator) GetDBRole() string

func (PostgresStorageConfigurator) GetDBTls

func (p PostgresStorageConfigurator) GetDBTls() string

func (PostgresStorageConfigurator) GetDBUserName

func (p PostgresStorageConfigurator) GetDBUserName() string

type Storage

type Storage interface {
	SaveCluster(cluster *domain.Cluster) error
	FindAllClusters() ([]*domain.Cluster, error)
	FindAllRouteConfigs() ([]*domain.RouteConfiguration, error)
	FindAllNodeGroups() ([]*domain.NodeGroup, error)
	FindAllListeners() ([]*domain.Listener, error)
	WithTx(f func(conn *bun.Conn) error) error
	BeforeQuery(ctx context.Context, queryEvent *bun.QueryEvent) context.Context
	AfterQuery(ctx context.Context, queryEvent *bun.QueryEvent)
	FindAllDeploymentVersions() ([]*domain.DeploymentVersion, error)
	FindAllEndpoints() ([]*domain.Endpoint, error)
	FindAllVirtualHosts() ([]*domain.VirtualHost, error)
	FindAllVirtualHostDomains() ([]*domain.VirtualHostDomain, error)
	UpdateVirtualHostDomainByOldDomain(domain *domain.VirtualHostDomain, oldDomain string) error
	FindAllRoutes() ([]*domain.Route, error)
	FindAllHeaderMatchers() ([]*domain.HeaderMatcher, error)
	FindAllHashPolicies() ([]*domain.HashPolicy, error)
	FindAllRetryPolicies() ([]*domain.RetryPolicy, error)
	FindAllClustersNodeGroups() ([]*domain.ClustersNodeGroup, error)
	FindAllListenerWasmFilters() ([]*domain.ListenersWasmFilter, error)
	Generate(uniqEntity domain.Unique) error
	FindAllEnvoyConfigVersions() ([]*domain.EnvoyConfigVersion, error)
	FindAllVirtualHostsDomains() ([]*domain.VirtualHostDomain, error)
	FindAllHealthChecks() ([]*domain.HealthCheck, error)
	FindAllTlsConfigs() ([]*domain.TlsConfig, error)
	FindWasmFilters() ([]*domain.WasmFilter, error)
	FindAllCompositeSatellites() ([]*domain.CompositeSatellite, error)
	FindAllStatefulSessionConfigs() ([]*domain.StatefulSession, error)
	FindAllElectionRecords() ([]*clustering.MasterMetadata, error)
	Migrate(ctx context.Context, db *bun.DB, migrations *migrate.Migrations) error
	FindAllRateLimits() ([]*domain.RateLimit, error)
	FindAllMicroserviceVersions() ([]*domain.MicroserviceVersion, error)
	FindAllExtAuthzFilters() ([]*domain.ExtAuthzFilter, error)
	FindAllCircuitBreakers() ([]*domain.CircuitBreaker, error)
	FindAllThresholds() ([]*domain.Threshold, error)
	FindAllTcpKeepalives() ([]*domain.TcpKeepalive, error)
	FindClusterByName(key string) (*domain.Cluster, error)
	FindTlsConfigByIdAndNodeGroupName(tlsConfigId int32, nodeGroupName string) (*domain.TlsConfigsNodeGroups, error)
	FindClustersNodeGroupByIdAndNodeGroup(clusterId int32, nodeGroup string) (*domain.ClustersNodeGroup, error)
	FindCompositeSatelliteByNamespace(namespace string) (*domain.CompositeSatellite, error)
	FindDeploymentVersionByName(version string) (*domain.DeploymentVersion, error)
	FindEndpointById(id int32) (*domain.Endpoint, error)
	FindHashPolicyById(id int32) (*domain.HashPolicy, error)
	FindHeaderMatcherById(id int32) (*domain.HeaderMatcher, error)
	FindHealthCheckById(id int32) (*domain.HealthCheck, error)
	FindListenerById(id int32) (*domain.Listener, error)
	FindRetryPolicyById(id int32) (*domain.RetryPolicy, error)
	FindRouteConfigById(id int32) (*domain.RouteConfiguration, error)
	FindRouteById(id int32) (*domain.Route, error)
	FindTlsConfigById(id int32) (*domain.TlsConfig, error)
	FindAllTlsConfigsNodeGroups() ([]*domain.TlsConfigsNodeGroups, error)
	FindVirtualHostById(id int32) (*domain.VirtualHost, error)
	FindWasmFilterById(id int32) (*domain.WasmFilter, error)
	FindStatefulSessionById(id int32) (*domain.StatefulSession, error)
	FindRateLimitByNameAndPriority(name string, priority domain.ConfigPriority) (*domain.RateLimit, error)
	FindNodeGroupByName(name string) (*domain.NodeGroup, error)
	FindExtAuthzFilterByName(name string) (*domain.ExtAuthzFilter, error)
	FindCircuitBreakerById(id int32) (*domain.CircuitBreaker, error)
	FindThresholdById(id int32) (*domain.Threshold, error)
	FindTcpKeepaliveById(id int32) (*domain.TcpKeepalive, error)
	FindAllNamespaces() ([]*domain.Namespace, error)
	SaveNamespace(namespace *domain.Namespace) error
	UpdateNamespaceByOldNamespace(namespace *domain.Namespace, oldNamespace string) error
	FindLuaFilters() ([]*domain.LuaFilter, error)
	FindLuaFilterById(id int32) (*domain.LuaFilter, error)
}

type StorageImpl

type StorageImpl struct {
	DbProvider db.DBProvider
	PGQuery    PGQueryWrapper
	PGConn     PGConnWrapper
	PGTx       PGTxWrapper
}

func NewConfiguredStorage added in v2.15.0

func NewConfiguredStorage(ctx context.Context) *StorageImpl

NewConfiguredStorage builds the storage on whichever database source this deployment uses: the Secret published by the DBaaS Operator, or the credentials core-bootstrap writes.

func NewStorage

func NewStorage(ctx context.Context, dbProvider db.DBProvider) *StorageImpl

NewStorage builds the storage on the given database pool, connects, and applies the migrations.

func (*StorageImpl) ActualizeNamespacesInDbAndEnv

func (s *StorageImpl) ActualizeNamespacesInDbAndEnv(ctx context.Context) error

func (StorageImpl) AfterQuery

func (s StorageImpl) AfterQuery(ctx context.Context, queryEvent *bun.QueryEvent)

func (StorageImpl) BeforeQuery

func (s StorageImpl) BeforeQuery(ctx context.Context, queryEvent *bun.QueryEvent) context.Context

=========================== implement db pg logging interface ===========================

func (*StorageImpl) FindAllCircuitBreakers

func (s *StorageImpl) FindAllCircuitBreakers() ([]*domain.CircuitBreaker, error)

func (*StorageImpl) FindAllClusters

func (s *StorageImpl) FindAllClusters() ([]*domain.Cluster, error)

func (*StorageImpl) FindAllClustersNodeGroups

func (s *StorageImpl) FindAllClustersNodeGroups() ([]*domain.ClustersNodeGroup, error)

func (*StorageImpl) FindAllCompositeSatellites

func (s *StorageImpl) FindAllCompositeSatellites() ([]*domain.CompositeSatellite, error)

func (*StorageImpl) FindAllDeploymentVersions

func (s *StorageImpl) FindAllDeploymentVersions() ([]*domain.DeploymentVersion, error)

func (*StorageImpl) FindAllElectionRecords

func (s *StorageImpl) FindAllElectionRecords() ([]*clustering.MasterMetadata, error)

func (*StorageImpl) FindAllEndpoints

func (s *StorageImpl) FindAllEndpoints() ([]*domain.Endpoint, error)

func (*StorageImpl) FindAllEnvoyConfigVersions

func (s *StorageImpl) FindAllEnvoyConfigVersions() ([]*domain.EnvoyConfigVersion, error)

func (*StorageImpl) FindAllExtAuthzFilters

func (s *StorageImpl) FindAllExtAuthzFilters() ([]*domain.ExtAuthzFilter, error)

func (*StorageImpl) FindAllHashPolicies

func (s *StorageImpl) FindAllHashPolicies() ([]*domain.HashPolicy, error)

func (*StorageImpl) FindAllHeaderMatchers

func (s *StorageImpl) FindAllHeaderMatchers() ([]*domain.HeaderMatcher, error)

func (*StorageImpl) FindAllHealthChecks

func (s *StorageImpl) FindAllHealthChecks() ([]*domain.HealthCheck, error)

func (*StorageImpl) FindAllListenerWasmFilters

func (s *StorageImpl) FindAllListenerWasmFilters() ([]*domain.ListenersWasmFilter, error)

func (*StorageImpl) FindAllListeners

func (s *StorageImpl) FindAllListeners() ([]*domain.Listener, error)

func (*StorageImpl) FindAllMicroserviceVersions

func (s *StorageImpl) FindAllMicroserviceVersions() ([]*domain.MicroserviceVersion, error)

func (*StorageImpl) FindAllNamespaces

func (s *StorageImpl) FindAllNamespaces() ([]*domain.Namespace, error)

func (*StorageImpl) FindAllNodeGroups

func (s *StorageImpl) FindAllNodeGroups() ([]*domain.NodeGroup, error)

func (*StorageImpl) FindAllRateLimits

func (s *StorageImpl) FindAllRateLimits() ([]*domain.RateLimit, error)

func (*StorageImpl) FindAllRetryPolicies

func (s *StorageImpl) FindAllRetryPolicies() ([]*domain.RetryPolicy, error)

func (*StorageImpl) FindAllRouteConfigs

func (s *StorageImpl) FindAllRouteConfigs() ([]*domain.RouteConfiguration, error)

func (*StorageImpl) FindAllRoutes

func (s *StorageImpl) FindAllRoutes() ([]*domain.Route, error)

func (*StorageImpl) FindAllStatefulSessionConfigs

func (s *StorageImpl) FindAllStatefulSessionConfigs() ([]*domain.StatefulSession, error)

func (*StorageImpl) FindAllTcpKeepalives

func (s *StorageImpl) FindAllTcpKeepalives() ([]*domain.TcpKeepalive, error)

func (*StorageImpl) FindAllThresholds

func (s *StorageImpl) FindAllThresholds() ([]*domain.Threshold, error)

func (*StorageImpl) FindAllTlsConfigs

func (s *StorageImpl) FindAllTlsConfigs() ([]*domain.TlsConfig, error)

func (*StorageImpl) FindAllTlsConfigsNodeGroups

func (s *StorageImpl) FindAllTlsConfigsNodeGroups() ([]*domain.TlsConfigsNodeGroups, error)

func (*StorageImpl) FindAllVirtualHostDomains

func (s *StorageImpl) FindAllVirtualHostDomains() ([]*domain.VirtualHostDomain, error)

func (*StorageImpl) FindAllVirtualHosts

func (s *StorageImpl) FindAllVirtualHosts() ([]*domain.VirtualHost, error)

func (*StorageImpl) FindAllVirtualHostsDomains

func (s *StorageImpl) FindAllVirtualHostsDomains() ([]*domain.VirtualHostDomain, error)

func (*StorageImpl) FindCircuitBreakerById

func (s *StorageImpl) FindCircuitBreakerById(id int32) (*domain.CircuitBreaker, error)

func (*StorageImpl) FindClusterByName

func (s *StorageImpl) FindClusterByName(key string) (*domain.Cluster, error)

func (*StorageImpl) FindClustersNodeGroupByIdAndNodeGroup

func (s *StorageImpl) FindClustersNodeGroupByIdAndNodeGroup(clusterId int32, nodeGroup string) (*domain.ClustersNodeGroup, error)

func (*StorageImpl) FindCompositeSatelliteByNamespace

func (s *StorageImpl) FindCompositeSatelliteByNamespace(namespace string) (*domain.CompositeSatellite, error)

func (*StorageImpl) FindDeploymentVersionByName

func (s *StorageImpl) FindDeploymentVersionByName(version string) (*domain.DeploymentVersion, error)

func (*StorageImpl) FindEndpointById

func (s *StorageImpl) FindEndpointById(id int32) (*domain.Endpoint, error)

func (*StorageImpl) FindExtAuthzFilterByName

func (s *StorageImpl) FindExtAuthzFilterByName(name string) (*domain.ExtAuthzFilter, error)

func (*StorageImpl) FindHashPolicyById

func (s *StorageImpl) FindHashPolicyById(id int32) (*domain.HashPolicy, error)

func (*StorageImpl) FindHeaderMatcherById

func (s *StorageImpl) FindHeaderMatcherById(id int32) (*domain.HeaderMatcher, error)

func (*StorageImpl) FindHealthCheckById

func (s *StorageImpl) FindHealthCheckById(id int32) (*domain.HealthCheck, error)

func (*StorageImpl) FindListenerById

func (s *StorageImpl) FindListenerById(id int32) (*domain.Listener, error)

func (*StorageImpl) FindLuaFilterById

func (s *StorageImpl) FindLuaFilterById(id int32) (*domain.LuaFilter, error)

func (*StorageImpl) FindLuaFilters

func (s *StorageImpl) FindLuaFilters() ([]*domain.LuaFilter, error)

func (*StorageImpl) FindNodeGroupByName

func (s *StorageImpl) FindNodeGroupByName(name string) (*domain.NodeGroup, error)

func (*StorageImpl) FindRateLimitByNameAndPriority

func (s *StorageImpl) FindRateLimitByNameAndPriority(name string, priority domain.ConfigPriority) (*domain.RateLimit, error)

func (*StorageImpl) FindRetryPolicyById

func (s *StorageImpl) FindRetryPolicyById(id int32) (*domain.RetryPolicy, error)

func (*StorageImpl) FindRouteById

func (s *StorageImpl) FindRouteById(id int32) (*domain.Route, error)

func (*StorageImpl) FindRouteConfigById

func (s *StorageImpl) FindRouteConfigById(id int32) (*domain.RouteConfiguration, error)

func (*StorageImpl) FindStatefulSessionById

func (s *StorageImpl) FindStatefulSessionById(id int32) (*domain.StatefulSession, error)

func (*StorageImpl) FindTcpKeepaliveById

func (s *StorageImpl) FindTcpKeepaliveById(id int32) (*domain.TcpKeepalive, error)

func (*StorageImpl) FindThresholdById

func (s *StorageImpl) FindThresholdById(id int32) (*domain.Threshold, error)

func (*StorageImpl) FindTlsConfigById

func (s *StorageImpl) FindTlsConfigById(id int32) (*domain.TlsConfig, error)

func (*StorageImpl) FindTlsConfigByIdAndNodeGroupName

func (s *StorageImpl) FindTlsConfigByIdAndNodeGroupName(tlsConfigId int32, nodeGroupName string) (*domain.TlsConfigsNodeGroups, error)

func (*StorageImpl) FindVirtualHostById

func (s *StorageImpl) FindVirtualHostById(id int32) (*domain.VirtualHost, error)

func (*StorageImpl) FindWasmFilterById

func (s *StorageImpl) FindWasmFilterById(id int32) (*domain.WasmFilter, error)

func (*StorageImpl) FindWasmFilters

func (s *StorageImpl) FindWasmFilters() ([]*domain.WasmFilter, error)

func (*StorageImpl) Generate

func (s *StorageImpl) Generate(uniqEntity domain.Unique) error

TODO performance gap

func (*StorageImpl) Migrate

func (s *StorageImpl) Migrate(ctx context.Context, db *bun.DB, migrations *migrate.Migrations) error

func (*StorageImpl) SaveCluster

func (s *StorageImpl) SaveCluster(cluster *domain.Cluster) error

func (*StorageImpl) SaveNamespace

func (s *StorageImpl) SaveNamespace(namespace *domain.Namespace) error

func (*StorageImpl) UpdateNamespaceByOldNamespace

func (s *StorageImpl) UpdateNamespaceByOldNamespace(namespace *domain.Namespace, oldNamespace string) error

func (*StorageImpl) UpdateVirtualHostDomainByOldDomain

func (s *StorageImpl) UpdateVirtualHostDomainByOldDomain(domain *domain.VirtualHostDomain, oldDomain string) error

func (*StorageImpl) WithTx

func (s *StorageImpl) WithTx(f func(conn *bun.Conn) error) error

func (*StorageImpl) WithTxBatch

func (s *StorageImpl) WithTxBatch(f func(tx BatchStorage) error) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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