driver_infrastructure

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: Apache-2.0 Imports: 22 Imported by: 8

Documentation

Index

Constants

View Source
const (
	BLUE_GREEN_SOURCE string = "BLUE_GREEN_DEPLOYMENT_SOURCE"
	BLUE_GREEN_TARGET string = "BLUE_GREEN_DEPLOYMENT_TARGET"
)
View Source
const (
	AVAILABLE                     string = "AVAILABLE"
	SWITCHOVER_INITIATED          string = "SWITCHOVER_INITIATED"
	SWITCHOVER_IN_PROGRESS        string = "SWITCHOVER_IN_PROGRESS"
	SWITCHOVER_IN_POST_PROCESSING string = "SWITCHOVER_IN_POST_PROCESSING"
	SWITCHOVER_COMPLETED          string = "SWITCHOVER_COMPLETED"
)
View Source
const (
	CUSTOM_ENDPOINT_PLUGIN_CODE                    string = "customEndpoint"
	BLUE_GREEN_PLUGIN_CODE                         string = "bg"
	READ_WRITE_SPLITTING_PLUGIN_CODE               string = "readWriteSplitting"
	FAILOVER_PLUGIN_CODE                           string = "failover"
	EFM_PLUGIN_CODE                                string = "efm"
	LIMITLESS_PLUGIN_CODE                          string = "limitless"
	IAM_PLUGIN_CODE                                string = "iam"
	SECRETS_MANAGER_PLUGIN_CODE                    string = "awsSecretsManager"
	ADFS_PLUGIN_CODE                               string = "federatedAuth"
	OKTA_PLUGIN_CODE                               string = "okta"
	EXECUTION_TIME_PLUGIN_CODE                     string = "executionTime"
	CONNECT_TIME_PLUGIN_CODE                       string = "connectTime"
	AURORA_CONNECTION_TRACKER_PLUGIN_CODE          string = "auroraConnectionTracker"
	DEVELOPER_PLUGIN_CODE                          string = "dev"
	AURORA_INITIAL_CONNECTION_STRATEGY_PLUGIN_CODE string = "initialConnection"
)
View Source
const (
	AURORA_MYSQL_DIALECT               string = "aurora-mysql"
	RDS_MYSQL_DIALECT                  string = "rds-mysql"
	MYSQL_DIALECT                      string = "mysql"
	RDS_MYSQL_MULTI_AZ_CLUSTER_DIALECT string = "rds-multi-az-mysql-cluster"
	AURORA_PG_DIALECT                  string = "aurora-pg"
	RDS_PG_DIALECT                     string = "rds-pg"
	PG_DIALECT                         string = "pg"
	RDS_PG_MULTI_AZ_CLUSTER_DIALECT    string = "rds-multi-az-pg-cluster"
)
View Source
const (
	AWS_PGX_DRIVER_CODE   string = "awssql-pgx"
	AWS_MYSQL_DRIVER_CODE string = "awssql-mysql"
)
View Source
const (
	SELECTOR_HIGHEST_WEIGHT  = "highestWeight"
	SELECTOR_RANDOM          = "random"
	SELECTOR_WEIGHTED_RANDOM = "weightedRandom"
	SELECTOR_ROUND_ROBIN     = "roundRobin"
)
View Source
const ROUND_ROBIN_DEFAULT_CACHE_EXPIRE_NANO = time.Duration(10) * time.Minute
View Source
const ROUND_ROBIN_DEFAULT_WEIGHT = 1

Variables

View Source
var (
	NOT_CREATED = BlueGreenPhase{"NOT_CREATED", 0, false}
	CREATED     = BlueGreenPhase{"CREATED", 1, false}
	PREPARATION = BlueGreenPhase{"PREPARATION", 2, true}
	IN_PROGRESS = BlueGreenPhase{"IN_PROGRESS", 3, true}
	POST        = BlueGreenPhase{"POST", 4, true}
	COMPLETED   = BlueGreenPhase{"COMPLETED", 5, true}
)
View Source
var (
	SOURCE = BlueGreenRole{"SOURCE", 0}
	TARGET = BlueGreenRole{"TARGET", 1}
)
View Source
var (
	// Example host weight pair patterns: "host0:3,host1:02,host2:1", "host.com:50000".
	HOST_WEIGHT_PAIR_PATTERN  = regexp.MustCompile("^(?P<host>[^:]+):(?P<weight>[0-9]+)$")
	HOST_PATTERN_GROUP        = "host"
	HOST_WEIGHT_PATTERN_GROUP = "weight"
)
View Source
var DEFAULT_TOPOLOGY_QUERY_TIMEOUT_MS = 5000
View Source
var EMPTY_ROUTING_RESULT_HOLDER = RoutingResultHolder{WrappedReturnValue: EMPTY_VAL}
View Source
var EMPTY_VAL = EmptyResult{}
View Source
var ENDPOINT_CACHE_EXPIRATION = time.Hour * 24
View Source
var FallbackTopologyRefreshTimeoutMs = 1100
View Source
var KnownDialectsByCode = map[string]DatabaseDialect{
	MYSQL_DIALECT:                      &MySQLDatabaseDialect{},
	PG_DIALECT:                         &PgDatabaseDialect{},
	RDS_MYSQL_DIALECT:                  &RdsMySQLDatabaseDialect{},
	RDS_PG_DIALECT:                     &RdsPgDatabaseDialect{},
	AURORA_MYSQL_DIALECT:               &AuroraMySQLDatabaseDialect{},
	AURORA_PG_DIALECT:                  &AuroraPgDatabaseDialect{},
	RDS_MYSQL_MULTI_AZ_CLUSTER_DIALECT: &RdsMultiAzClusterMySQLDatabaseDialect{},
	RDS_PG_MULTI_AZ_CLUSTER_DIALECT:    &RdsMultiAzClusterPgDatabaseDialect{},
}
View Source
var MONITOR_EXPIRATION_NANOS = time.Minute
View Source
var TOPOLOGY_CACHE_EXPIRATION_NANO = time.Minute * 5
View Source
var TopologyCache = utils.NewCache[[]*host_info_util.HostInfo]()

Functions

func ClearAllRdsHostListProviderCaches

func ClearAllRdsHostListProviderCaches()

func ClearCaches

func ClearCaches()

This cleans up all long-standing caches. To be called at the end of program, not each time a Conn is closed.

func ClearResetSessionStateOnCloseFunc

func ClearResetSessionStateOnCloseFunc()

func ClearTransferSessionStateOnCloseFunc

func ClearTransferSessionStateOnCloseFunc()

func GetHostWeightMapFromString

func GetHostWeightMapFromString(hostWeightMapString string) (map[string]int, error)

func GetResetSessionStateOnCloseFunc

func GetResetSessionStateOnCloseFunc() func(sessionState SessionState, conn driver.Conn) bool

func GetTransferSessionStateOnCloseFunc

func GetTransferSessionStateOnCloseFunc() func(sessionState SessionState, conn driver.Conn) bool

func MonitoringRdsHostListProviderClearCaches

func MonitoringRdsHostListProviderClearCaches()

func ResetCustomConnectionProvider

func ResetCustomConnectionProvider()

func SetCustomConnectionProvider

func SetCustomConnectionProvider(connProvider ConnectionProvider)

func SetResetSessionStateOnCloseFunc

func SetResetSessionStateOnCloseFunc(function func(sessionState SessionState, conn driver.Conn) bool)

func SetTransferSessionStateOnCloseFunc

func SetTransferSessionStateOnCloseFunc(function func(sessionState SessionState, conn driver.Conn) bool)

Types

type AllowedAndBlockedHosts added in v1.2.0

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

func NewAllowedAndBlockedHosts added in v1.2.0

func NewAllowedAndBlockedHosts(
	allowedHostIds map[string]bool,
	blockedHostIds map[string]bool) *AllowedAndBlockedHosts

func (*AllowedAndBlockedHosts) GetAllowedHostIds added in v1.2.0

func (a *AllowedAndBlockedHosts) GetAllowedHostIds() map[string]bool

func (*AllowedAndBlockedHosts) GetBlockedHostIds added in v1.2.0

func (a *AllowedAndBlockedHosts) GetBlockedHostIds() map[string]bool

type AuroraLimitlessDialect

type AuroraLimitlessDialect interface {
	GetLimitlessRouterEndpointQuery() string
	DatabaseDialect
}

type AuroraMySQLDatabaseDialect

type AuroraMySQLDatabaseDialect struct {
	MySQLTopologyAwareDatabaseDialect
}

func (*AuroraMySQLDatabaseDialect) GetBlueGreenStatus added in v1.1.0

func (m *AuroraMySQLDatabaseDialect) GetBlueGreenStatus(conn driver.Conn) []BlueGreenResult

func (*AuroraMySQLDatabaseDialect) GetDialectUpdateCandidates

func (m *AuroraMySQLDatabaseDialect) GetDialectUpdateCandidates() []string

func (*AuroraMySQLDatabaseDialect) GetHostListProvider

func (m *AuroraMySQLDatabaseDialect) GetHostListProvider(
	props *utils.RWMap[string, string],
	hostListProviderService HostListProviderService,
	pluginService PluginService) HostListProvider

func (*AuroraMySQLDatabaseDialect) GetHostName

func (m *AuroraMySQLDatabaseDialect) GetHostName(conn driver.Conn) string

func (*AuroraMySQLDatabaseDialect) GetTopology

func (*AuroraMySQLDatabaseDialect) GetWriterHostName

func (m *AuroraMySQLDatabaseDialect) GetWriterHostName(conn driver.Conn) (string, error)

func (*AuroraMySQLDatabaseDialect) IsBlueGreenStatusAvailable added in v1.1.0

func (m *AuroraMySQLDatabaseDialect) IsBlueGreenStatusAvailable(conn driver.Conn) bool

func (*AuroraMySQLDatabaseDialect) IsDialect

func (m *AuroraMySQLDatabaseDialect) IsDialect(conn driver.Conn) bool

type AuroraPgDatabaseDialect

type AuroraPgDatabaseDialect struct {
	PgTopologyAwareDatabaseDialect
}

func (*AuroraPgDatabaseDialect) GetBlueGreenStatus added in v1.1.0

func (m *AuroraPgDatabaseDialect) GetBlueGreenStatus(conn driver.Conn) []BlueGreenResult

func (*AuroraPgDatabaseDialect) GetDialectUpdateCandidates

func (m *AuroraPgDatabaseDialect) GetDialectUpdateCandidates() []string

func (*AuroraPgDatabaseDialect) GetHostListProvider

func (m *AuroraPgDatabaseDialect) GetHostListProvider(
	props *utils.RWMap[string, string],
	hostListProviderService HostListProviderService,
	pluginService PluginService) HostListProvider

func (*AuroraPgDatabaseDialect) GetHostName

func (m *AuroraPgDatabaseDialect) GetHostName(conn driver.Conn) string

func (*AuroraPgDatabaseDialect) GetLimitlessRouterEndpointQuery

func (m *AuroraPgDatabaseDialect) GetLimitlessRouterEndpointQuery() string

func (*AuroraPgDatabaseDialect) GetTopology

func (m *AuroraPgDatabaseDialect) GetTopology(conn driver.Conn, provider HostListProvider) ([]*host_info_util.HostInfo, error)

func (*AuroraPgDatabaseDialect) GetWriterHostName

func (m *AuroraPgDatabaseDialect) GetWriterHostName(conn driver.Conn) (string, error)

func (*AuroraPgDatabaseDialect) IsBlueGreenStatusAvailable added in v1.1.0

func (m *AuroraPgDatabaseDialect) IsBlueGreenStatusAvailable(conn driver.Conn) bool

func (*AuroraPgDatabaseDialect) IsDialect

func (m *AuroraPgDatabaseDialect) IsDialect(conn driver.Conn) bool

type BlockingHostListProvider

type BlockingHostListProvider interface {
	HostListProvider
	ForceRefreshHostListWithTimeout(shouldVerifyWriter bool, timeoutMs int) ([]*host_info_util.HostInfo, error)
}

type BlueGreenDialect added in v1.1.0

type BlueGreenDialect interface {
	GetBlueGreenStatus(conn driver.Conn) []BlueGreenResult
	IsBlueGreenStatusAvailable(conn driver.Conn) bool
	DatabaseDialect
}

type BlueGreenIntervalRate added in v1.1.0

type BlueGreenIntervalRate int
const (
	INVALID BlueGreenIntervalRate = iota - 1
	BASELINE
	INCREASED
	HIGH
)

type BlueGreenPhase added in v1.1.0

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

func ParsePhase added in v1.1.0

func ParsePhase(statusKey string) BlueGreenPhase

func (BlueGreenPhase) Equals added in v1.1.0

func (b BlueGreenPhase) Equals(other BlueGreenPhase) bool

func (BlueGreenPhase) GetName added in v1.1.0

func (b BlueGreenPhase) GetName() string

func (BlueGreenPhase) GetPhase added in v1.1.0

func (b BlueGreenPhase) GetPhase() int

func (BlueGreenPhase) IsActiveSwitchoverOrCompleted added in v1.1.0

func (b BlueGreenPhase) IsActiveSwitchoverOrCompleted() bool

func (BlueGreenPhase) IsZero added in v1.1.0

func (b BlueGreenPhase) IsZero() bool

type BlueGreenResult added in v1.1.0

type BlueGreenResult struct {
	Version  string
	Endpoint string
	Port     int
	Role     string
	Status   string
}

func (*BlueGreenResult) String added in v1.1.0

func (b *BlueGreenResult) String() string

type BlueGreenRole added in v1.1.0

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

func ParseRole added in v1.1.0

func ParseRole(roleKey string) BlueGreenRole

func (BlueGreenRole) GetName added in v1.1.0

func (b BlueGreenRole) GetName() string

func (BlueGreenRole) GetValue added in v1.1.0

func (b BlueGreenRole) GetValue() int

func (BlueGreenRole) IsZero added in v1.1.0

func (b BlueGreenRole) IsZero() bool

func (BlueGreenRole) String added in v1.1.0

func (b BlueGreenRole) String() string

type BlueGreenStatus added in v1.1.0

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

func NewBgStatus added in v1.1.0

func NewBgStatus(id string, phase BlueGreenPhase, connectRoutings []ConnectRouting, executeRoutings []ExecuteRouting,
	roleByHost *utils.RWMap[string, BlueGreenRole], correspondingHosts *utils.RWMap[string, utils.Pair[*host_info_util.HostInfo, *host_info_util.HostInfo]]) BlueGreenStatus

func (BlueGreenStatus) GetBgId added in v1.1.0

func (b BlueGreenStatus) GetBgId() string

func (BlueGreenStatus) GetConnectRoutings added in v1.1.0

func (b BlueGreenStatus) GetConnectRoutings() []ConnectRouting

func (BlueGreenStatus) GetCorrespondingHosts added in v1.1.0

func (b BlueGreenStatus) GetCorrespondingHosts() map[string]utils.Pair[*host_info_util.HostInfo, *host_info_util.HostInfo]

func (BlueGreenStatus) GetCurrentPhase added in v1.1.0

func (b BlueGreenStatus) GetCurrentPhase() BlueGreenPhase

func (BlueGreenStatus) GetExecuteRoutings added in v1.1.0

func (b BlueGreenStatus) GetExecuteRoutings() []ExecuteRouting

func (BlueGreenStatus) GetRole added in v1.1.0

func (b BlueGreenStatus) GetRole(hostInfo *host_info_util.HostInfo) (role BlueGreenRole, ok bool)

func (BlueGreenStatus) IsZero added in v1.1.0

func (b BlueGreenStatus) IsZero() bool

func (BlueGreenStatus) MatchIdPhaseAndLen added in v1.1.0

func (b BlueGreenStatus) MatchIdPhaseAndLen(other BlueGreenStatus) bool

func (BlueGreenStatus) String added in v1.1.0

func (b BlueGreenStatus) String() string

type CanReleaseResources

type CanReleaseResources interface {
	ReleaseResources()
}

type ClusterTopologyMonitor

type ClusterTopologyMonitor interface {
	SetClusterId(clusterId string)
	ForceRefreshVerifyWriter(writerImportant bool, timeoutMs int) ([]*host_info_util.HostInfo, error)
	ForceRefreshUsingConn(conn driver.Conn, timeoutMs int) ([]*host_info_util.HostInfo, error)
	Close()
	Start(wg *sync.WaitGroup)
}

type ClusterTopologyMonitorImpl

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

func NewClusterTopologyMonitorImpl

func NewClusterTopologyMonitorImpl(
	hostListProvider *MonitoringRdsHostListProvider,
	dialect TopologyAwareDialect,
	clusterId string,
	highRefreshRateNano time.Duration,
	refreshRateNano time.Duration,
	topologyCacheExpirationNano time.Duration,
	props *utils.RWMap[string, string],
	initialHostInfo *host_info_util.HostInfo,
	clusterInstanceTemplate *host_info_util.HostInfo,
	pluginService PluginService) *ClusterTopologyMonitorImpl

func (*ClusterTopologyMonitorImpl) Close

func (c *ClusterTopologyMonitorImpl) Close()

func (*ClusterTopologyMonitorImpl) ForceRefreshUsingConn

func (c *ClusterTopologyMonitorImpl) ForceRefreshUsingConn(conn driver.Conn, timeoutMs int) ([]*host_info_util.HostInfo, error)

func (*ClusterTopologyMonitorImpl) ForceRefreshVerifyWriter

func (c *ClusterTopologyMonitorImpl) ForceRefreshVerifyWriter(shouldVerify bool, timeoutMs int) ([]*host_info_util.HostInfo, error)

func (*ClusterTopologyMonitorImpl) Run

func (*ClusterTopologyMonitorImpl) SetClusterId

func (c *ClusterTopologyMonitorImpl) SetClusterId(clusterId string)

func (*ClusterTopologyMonitorImpl) Start

type ConnectFunc

type ConnectFunc func(props *utils.RWMap[string, string]) (driver.Conn, error)

type ConnectRouting added in v1.1.0

type ConnectRouting interface {
	IsMatch(hostInfo *host_info_util.HostInfo, hostRole BlueGreenRole) bool

	Apply(
		plugin ConnectionPlugin,
		hostInfo *host_info_util.HostInfo,
		properties *utils.RWMap[string, string],
		isInitialConnection bool,
		pluginService PluginService,
	) (driver.Conn, error)
}

type ConnectionContainer

type ConnectionContainer struct {
	Conn driver.Conn
}

type ConnectionPlugin

type ConnectionPlugin interface {
	GetSubscribedMethods() []string
	Execute(
		connInvokedOn driver.Conn,
		methodName string,
		executeFunc ExecuteFunc,
		methodArgs ...any) (wrappedReturnValue any, wrappedReturnValue2 any, wrappedOk bool, wrappedErr error)
	Connect(hostInfo *host_info_util.HostInfo, props *utils.RWMap[string, string], isInitialConnection bool, connectFunc ConnectFunc) (driver.Conn, error)
	ForceConnect(hostInfo *host_info_util.HostInfo, props *utils.RWMap[string, string], isInitialConnection bool, connectFunc ConnectFunc) (driver.Conn, error)
	AcceptsStrategy(strategy string) bool
	GetHostInfoByStrategy(role host_info_util.HostRole, strategy string, hosts []*host_info_util.HostInfo) (*host_info_util.HostInfo, error)
	GetHostSelectorStrategy(strategy string) (HostSelector, error)
	NotifyConnectionChanged(changes map[HostChangeOptions]bool) OldConnectionSuggestedAction
	NotifyHostListChanged(changes map[string]map[HostChangeOptions]bool)
	InitHostProvider(props *utils.RWMap[string, string], hostListProviderService HostListProviderService, initHostProviderFunc func() error) error
	GetPluginCode() string
}

type ConnectionPluginFactory

type ConnectionPluginFactory interface {
	GetInstance(pluginService PluginService, props *utils.RWMap[string, string]) (ConnectionPlugin, error)
	ClearCaches()
}

type ConnectionProvider

type ConnectionProvider interface {
	AcceptsUrl(hostInfo host_info_util.HostInfo, props map[string]string) bool
	AcceptsStrategy(strategy string) bool
	GetHostInfoByStrategy(hosts []*host_info_util.HostInfo, role host_info_util.HostRole, strategy string, props map[string]string) (*host_info_util.HostInfo, error)
	GetHostSelectorStrategy(strategy string) (HostSelector, error)
	Connect(hostInfo *host_info_util.HostInfo, props map[string]string, pluginService PluginService) (driver.Conn, error)
}

type ConnectionProviderManager

type ConnectionProviderManager struct {
	DefaultProvider   ConnectionProvider
	EffectiveProvider ConnectionProvider
}

func (*ConnectionProviderManager) AcceptsStrategy

func (connProviderManager *ConnectionProviderManager) AcceptsStrategy(strategy string) bool

func (*ConnectionProviderManager) GetConnectionProvider

func (connProviderManager *ConnectionProviderManager) GetConnectionProvider(
	hostInfo host_info_util.HostInfo,
	rwProps *utils.RWMap[string, string]) ConnectionProvider

func (*ConnectionProviderManager) GetDefaultProvider

func (connProviderManager *ConnectionProviderManager) GetDefaultProvider() ConnectionProvider

func (*ConnectionProviderManager) GetHostInfoByStrategy

func (connProviderManager *ConnectionProviderManager) GetHostInfoByStrategy(
	hosts []*host_info_util.HostInfo,
	role host_info_util.HostRole,
	strategy string,
	rwProps *utils.RWMap[string, string]) (*host_info_util.HostInfo, error)

func (*ConnectionProviderManager) GetHostSelectorStrategy

func (connProviderManager *ConnectionProviderManager) GetHostSelectorStrategy(strategy string) (HostSelector, error)

type DatabaseDialect

type DatabaseDialect interface {
	GetDefaultPort() int
	GetHostAliasQuery() string
	GetServerVersionQuery() string
	GetDialectUpdateCandidates() []string
	IsDialect(conn driver.Conn) bool
	GetHostListProvider(props *utils.RWMap[string, string], hostListProviderService HostListProviderService, pluginService PluginService) HostListProvider
	DoesStatementSetAutoCommit(statement string) (bool, bool)
	DoesStatementSetReadOnly(statement string) (bool, bool)
	DoesStatementSetCatalog(statement string) (string, bool)
	DoesStatementSetSchema(statement string) (string, bool)
	DoesStatementSetTransactionIsolation(statement string) (TransactionIsolationLevel, bool)
	GetSetAutoCommitQuery(autoCommit bool) (string, error)
	GetSetReadOnlyQuery(readOnly bool) (string, error)
	GetSetCatalogQuery(catalog string) (string, error)
	GetSetSchemaQuery(schema string) (string, error)
	GetSetTransactionIsolationQuery(level TransactionIsolationLevel) (string, error)
}

type DatabaseEngine

type DatabaseEngine string
const (
	MYSQL DatabaseEngine = "mysql"
	PG    DatabaseEngine = "pg"
)

type DialectCode

type DialectCode string

type DialectManager

type DialectManager struct {
	FindRegisteredDriver func(dialectCode string) bool
	// contains filtered or unexported fields
}

func (*DialectManager) GetDialect

func (d *DialectManager) GetDialect(dsn string, props *utils.RWMap[string, string]) (DatabaseDialect, error)

func (*DialectManager) GetDialectForUpdate

func (d *DialectManager) GetDialectForUpdate(conn driver.Conn, originalHost string, newHost string) DatabaseDialect

type DialectProvider

type DialectProvider interface {
	GetDialect(dsn string, props *utils.RWMap[string, string]) (DatabaseDialect, error)
	GetDialectForUpdate(conn driver.Conn, originalHost string, newHost string) DatabaseDialect
}

type DriverConnectionProvider

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

func NewDriverConnectionProvider

func NewDriverConnectionProvider(targetDriver driver.Driver) *DriverConnectionProvider

func (DriverConnectionProvider) AcceptsStrategy

func (d DriverConnectionProvider) AcceptsStrategy(strategy string) bool

func (DriverConnectionProvider) AcceptsUrl

func (d DriverConnectionProvider) AcceptsUrl(hostInfo host_info_util.HostInfo, props map[string]string) bool

func (DriverConnectionProvider) Connect

func (d DriverConnectionProvider) Connect(hostInfo *host_info_util.HostInfo, props map[string]string, pluginService PluginService) (driver.Conn, error)

func (DriverConnectionProvider) GetHostInfoByStrategy

func (d DriverConnectionProvider) GetHostInfoByStrategy(
	hosts []*host_info_util.HostInfo,
	role host_info_util.HostRole,
	strategy string,
	props map[string]string) (*host_info_util.HostInfo, error)

func (DriverConnectionProvider) GetHostSelectorStrategy

func (d DriverConnectionProvider) GetHostSelectorStrategy(strategy string) (HostSelector, error)

type DriverDialect

type DriverDialect interface {
	IsDialect(driver driver.Driver) bool
	GetAllowedOnConnectionMethodNames() []string
	PrepareDsn(properties map[string]string, info *host_info_util.HostInfo) string
	IsNetworkError(err error) bool
	IsLoginError(err error) bool
	IsClosed(conn driver.Conn) bool
	IsDriverRegistered(drivers map[string]driver.Driver) bool
	RegisterDriver()
	GetDriverRegistrationName() string
}

type DsnHostListProvider

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

func NewDsnHostListProvider

func NewDsnHostListProvider(props *utils.RWMap[string, string], hostListProviderService HostListProviderService) *DsnHostListProvider

func (*DsnHostListProvider) CreateHost

func (c *DsnHostListProvider) CreateHost(hostName string, hostRole host_info_util.HostRole, lag float64, cpu float64, lastUpdateTime time.Time) *host_info_util.HostInfo

func (*DsnHostListProvider) ForceRefresh

func (c *DsnHostListProvider) ForceRefresh(_ driver.Conn) ([]*host_info_util.HostInfo, error)

func (*DsnHostListProvider) GetClusterId

func (c *DsnHostListProvider) GetClusterId() (clusterId string, err error)

func (*DsnHostListProvider) GetHostRole

func (*DsnHostListProvider) IdentifyConnection

func (c *DsnHostListProvider) IdentifyConnection(_ driver.Conn) (*host_info_util.HostInfo, error)

func (*DsnHostListProvider) IsStaticHostListProvider

func (c *DsnHostListProvider) IsStaticHostListProvider() bool

func (*DsnHostListProvider) Refresh

type EmptyResult added in v1.1.0

type EmptyResult struct{}

type ExecuteFunc

type ExecuteFunc func() (any, any, bool, error)

type ExecuteRouting added in v1.1.0

type ExecuteRouting interface {
	IsMatch(hostInfo *host_info_util.HostInfo, hostRole BlueGreenRole) bool
	Apply(
		plugin ConnectionPlugin,
		properties *utils.RWMap[string, string],
		pluginService PluginService,
		methodName string,
		methodFunc ExecuteFunc,
		methodArgs ...any,
	) RoutingResultHolder
}

type HighestWeightHostSelector

type HighestWeightHostSelector struct{}

func (*HighestWeightHostSelector) GetHost

type HostChangeOptions

type HostChangeOptions int
const (
	HOSTNAME                  HostChangeOptions = 0
	WENT_UP                   HostChangeOptions = 3
	WENT_DOWN                 HostChangeOptions = 4
	CONNECTION_OBJECT_CHANGED HostChangeOptions = 5
	INITIAL_CONNECTION        HostChangeOptions = 6
	HOST_ADDED                HostChangeOptions = 7
	HOST_CHANGED              HostChangeOptions = 8
	HOST_DELETED              HostChangeOptions = 9
)

type HostListProvider

type HostListProvider interface {
	Refresh(conn driver.Conn) ([]*host_info_util.HostInfo, error)
	ForceRefresh(conn driver.Conn) ([]*host_info_util.HostInfo, error)
	GetHostRole(conn driver.Conn) host_info_util.HostRole
	IdentifyConnection(conn driver.Conn) (*host_info_util.HostInfo, error)
	GetClusterId() (string, error)
	IsStaticHostListProvider() bool
	CreateHost(hostName string, role host_info_util.HostRole, lag float64, cpu float64, lastUpdateTime time.Time) *host_info_util.HostInfo
}

type HostListProviderService

type HostListProviderService interface {
	IsStaticHostListProvider() bool
	CreateHostListProvider(props *utils.RWMap[string, string]) HostListProvider
	GetHostListProvider() HostListProvider
	SetHostListProvider(hostListProvider HostListProvider)
	SetInitialConnectionHostInfo(info *host_info_util.HostInfo)
	GetDialect() DatabaseDialect
	GetCurrentConnection() driver.Conn
}

type HostMonitoringRoutine

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

func (*HostMonitoringRoutine) Init

func (h *HostMonitoringRoutine) Init()

type HostSelector

type HostSelector interface {
	GetHost(hosts []*host_info_util.HostInfo, role host_info_util.HostRole, props map[string]string) (*host_info_util.HostInfo, error)
}

type MonitoringRdsHostListProvider

type MonitoringRdsHostListProvider struct {
	*RdsHostListProvider
	// contains filtered or unexported fields
}

func NewMonitoringRdsHostListProvider

func NewMonitoringRdsHostListProvider(
	hostListProviderService HostListProviderService,
	databaseDialect TopologyAwareDialect,
	properties *utils.RWMap[string, string],
	pluginService PluginService) *MonitoringRdsHostListProvider

func (*MonitoringRdsHostListProvider) ForceRefreshHostListWithTimeout

func (m *MonitoringRdsHostListProvider) ForceRefreshHostListWithTimeout(shouldVerifyWriter bool, timeoutMs int) ([]*host_info_util.HostInfo, error)

type MySQLDatabaseDialect

type MySQLDatabaseDialect struct {
}

func (*MySQLDatabaseDialect) DoesStatementSetAutoCommit

func (m *MySQLDatabaseDialect) DoesStatementSetAutoCommit(statement string) (bool, bool)

func (*MySQLDatabaseDialect) DoesStatementSetCatalog

func (m *MySQLDatabaseDialect) DoesStatementSetCatalog(statement string) (string, bool)

func (*MySQLDatabaseDialect) DoesStatementSetReadOnly

func (m *MySQLDatabaseDialect) DoesStatementSetReadOnly(statement string) (bool, bool)

func (*MySQLDatabaseDialect) DoesStatementSetSchema

func (m *MySQLDatabaseDialect) DoesStatementSetSchema(_ string) (string, bool)

func (*MySQLDatabaseDialect) DoesStatementSetTransactionIsolation

func (m *MySQLDatabaseDialect) DoesStatementSetTransactionIsolation(statement string) (TransactionIsolationLevel, bool)

func (*MySQLDatabaseDialect) GetDefaultPort

func (m *MySQLDatabaseDialect) GetDefaultPort() int

func (*MySQLDatabaseDialect) GetDialectUpdateCandidates

func (m *MySQLDatabaseDialect) GetDialectUpdateCandidates() []string

func (*MySQLDatabaseDialect) GetHostAliasQuery

func (m *MySQLDatabaseDialect) GetHostAliasQuery() string

func (*MySQLDatabaseDialect) GetHostListProvider

func (m *MySQLDatabaseDialect) GetHostListProvider(
	props *utils.RWMap[string, string],
	hostListProviderService HostListProviderService,
	_ PluginService) HostListProvider

func (*MySQLDatabaseDialect) GetServerVersionQuery

func (m *MySQLDatabaseDialect) GetServerVersionQuery() string

func (*MySQLDatabaseDialect) GetSetAutoCommitQuery

func (m *MySQLDatabaseDialect) GetSetAutoCommitQuery(autoCommit bool) (string, error)

func (*MySQLDatabaseDialect) GetSetCatalogQuery

func (m *MySQLDatabaseDialect) GetSetCatalogQuery(catalog string) (string, error)

func (*MySQLDatabaseDialect) GetSetReadOnlyQuery

func (m *MySQLDatabaseDialect) GetSetReadOnlyQuery(readOnly bool) (string, error)

func (*MySQLDatabaseDialect) GetSetSchemaQuery

func (m *MySQLDatabaseDialect) GetSetSchemaQuery(_ string) (string, error)

func (*MySQLDatabaseDialect) GetSetTransactionIsolationQuery

func (m *MySQLDatabaseDialect) GetSetTransactionIsolationQuery(level TransactionIsolationLevel) (string, error)

func (*MySQLDatabaseDialect) IsDialect

func (m *MySQLDatabaseDialect) IsDialect(conn driver.Conn) bool

type MySQLTopologyAwareDatabaseDialect

type MySQLTopologyAwareDatabaseDialect struct {
	MySQLDatabaseDialect
}

func (*MySQLTopologyAwareDatabaseDialect) GetHostListProvider

func (m *MySQLTopologyAwareDatabaseDialect) GetHostListProvider(
	props *utils.RWMap[string, string],
	hostListProviderService HostListProviderService,
	pluginService PluginService) HostListProvider

func (*MySQLTopologyAwareDatabaseDialect) GetHostName

func (*MySQLTopologyAwareDatabaseDialect) GetHostRole

func (*MySQLTopologyAwareDatabaseDialect) GetTopology

func (*MySQLTopologyAwareDatabaseDialect) GetWriterHostName

func (m *MySQLTopologyAwareDatabaseDialect) GetWriterHostName(_ driver.Conn) (string, error)

type NumberRange

type NumberRange struct {
	Start int
	End   int
}

func (NumberRange) IsInNumberRange

func (nr NumberRange) IsInNumberRange(n int) bool

type OldConnectionSuggestedAction

type OldConnectionSuggestedAction string
const (
	NO_OPINION OldConnectionSuggestedAction = "no_opinion"
	DISPOSE    OldConnectionSuggestedAction = "dispose"
	PRESERVE   OldConnectionSuggestedAction = "preserve"
)

type PgDatabaseDialect

type PgDatabaseDialect struct {
}

func (*PgDatabaseDialect) DoesStatementSetAutoCommit

func (p *PgDatabaseDialect) DoesStatementSetAutoCommit(_ string) (bool, bool)

func (*PgDatabaseDialect) DoesStatementSetCatalog

func (p *PgDatabaseDialect) DoesStatementSetCatalog(_ string) (string, bool)

func (*PgDatabaseDialect) DoesStatementSetReadOnly

func (p *PgDatabaseDialect) DoesStatementSetReadOnly(statement string) (bool, bool)

func (*PgDatabaseDialect) DoesStatementSetSchema

func (p *PgDatabaseDialect) DoesStatementSetSchema(statement string) (string, bool)

func (*PgDatabaseDialect) DoesStatementSetTransactionIsolation

func (p *PgDatabaseDialect) DoesStatementSetTransactionIsolation(statement string) (TransactionIsolationLevel, bool)

func (*PgDatabaseDialect) GetDefaultPort

func (p *PgDatabaseDialect) GetDefaultPort() int

func (*PgDatabaseDialect) GetDialectUpdateCandidates

func (p *PgDatabaseDialect) GetDialectUpdateCandidates() []string

func (*PgDatabaseDialect) GetHostAliasQuery

func (p *PgDatabaseDialect) GetHostAliasQuery() string

func (*PgDatabaseDialect) GetHostListProvider

func (p *PgDatabaseDialect) GetHostListProvider(
	props *utils.RWMap[string, string],
	hostListProviderService HostListProviderService,
	_ PluginService) HostListProvider

func (*PgDatabaseDialect) GetServerVersionQuery

func (p *PgDatabaseDialect) GetServerVersionQuery() string

func (*PgDatabaseDialect) GetSetAutoCommitQuery

func (p *PgDatabaseDialect) GetSetAutoCommitQuery(_ bool) (string, error)

func (*PgDatabaseDialect) GetSetCatalogQuery

func (p *PgDatabaseDialect) GetSetCatalogQuery(_ string) (string, error)

func (*PgDatabaseDialect) GetSetReadOnlyQuery

func (p *PgDatabaseDialect) GetSetReadOnlyQuery(readOnly bool) (string, error)

func (*PgDatabaseDialect) GetSetSchemaQuery

func (p *PgDatabaseDialect) GetSetSchemaQuery(schema string) (string, error)

func (*PgDatabaseDialect) GetSetTransactionIsolationQuery

func (p *PgDatabaseDialect) GetSetTransactionIsolationQuery(level TransactionIsolationLevel) (string, error)

func (*PgDatabaseDialect) IsDialect

func (p *PgDatabaseDialect) IsDialect(conn driver.Conn) bool

type PgTopologyAwareDatabaseDialect

type PgTopologyAwareDatabaseDialect struct {
	PgDatabaseDialect
}

func (*PgTopologyAwareDatabaseDialect) GetHostListProvider

func (m *PgTopologyAwareDatabaseDialect) GetHostListProvider(
	props *utils.RWMap[string, string],
	hostListProviderService HostListProviderService,
	pluginService PluginService) HostListProvider

func (*PgTopologyAwareDatabaseDialect) GetHostName

func (*PgTopologyAwareDatabaseDialect) GetHostRole

func (*PgTopologyAwareDatabaseDialect) GetTopology

func (*PgTopologyAwareDatabaseDialect) GetWriterHostName

func (m *PgTopologyAwareDatabaseDialect) GetWriterHostName(_ driver.Conn) (string, error)

type PluginConnectFunc

type PluginConnectFunc func(
	plugin ConnectionPlugin,
	props *utils.RWMap[string, string],
	targetFunc func(props *utils.RWMap[string, string]) (driver.Conn, error)) (driver.Conn, error)

type PluginExecFunc

type PluginExecFunc func(plugin ConnectionPlugin, targetFunc func() (any, any, bool, error)) (any, any, bool, error)

type PluginManager

type PluginManager interface {
	Init(pluginService PluginService, plugins []ConnectionPlugin) error
	InitHostProvider(props *utils.RWMap[string, string], hostListProviderService HostListProviderService) error
	Connect(hostInfo *host_info_util.HostInfo, props *utils.RWMap[string, string], isInitialConnection bool, pluginToSkip ConnectionPlugin) (driver.Conn, error)
	ForceConnect(hostInfo *host_info_util.HostInfo, props *utils.RWMap[string, string], isInitialConnection bool) (driver.Conn, error)
	Execute(connInvokedOn driver.Conn, name string, methodFunc ExecuteFunc, methodArgs ...any) (
		wrappedReturnValue any,
		wrappedReturnValue2 any,
		wrappedOk bool,
		wrappedErr error)
	AcceptsStrategy(strategy string) bool
	NotifyHostListChanged(changes map[string]map[HostChangeOptions]bool)
	NotifyConnectionChanged(
		changes map[HostChangeOptions]bool, skipNotificationForThisPlugin ConnectionPlugin) map[OldConnectionSuggestedAction]bool
	NotifySubscribedPlugins(methodName string, pluginFunc PluginExecFunc, skipNotificationForThisPlugin ConnectionPlugin) error
	GetHostInfoByStrategy(role host_info_util.HostRole, strategy string, hosts []*host_info_util.HostInfo) (*host_info_util.HostInfo, error)
	GetHostSelectorStrategy(strategy string) (hostSelector HostSelector, err error)
	GetDefaultConnectionProvider() ConnectionProvider
	GetEffectiveConnectionProvider() ConnectionProvider
	GetConnectionProviderManager() ConnectionProviderManager
	GetTelemetryContext() context.Context
	GetTelemetryFactory() telemetry.TelemetryFactory
	SetTelemetryContext(ctx context.Context)
	IsPluginInUse(pluginName string) bool
	ReleaseResources()
	UnwrapPlugin(pluginCode string) ConnectionPlugin
}

type PluginManagerProvider

type PluginManagerProvider func(
	targetDriver driver.Driver,
	props *utils.RWMap[string, string],
	connProviderManager ConnectionProviderManager,
	telemetryFactory telemetry.TelemetryFactory) PluginManager

type PluginService

type PluginService interface {
	GetCurrentConnection() driver.Conn
	GetCurrentConnectionRef() *driver.Conn
	SetCurrentConnection(conn driver.Conn, hostInfo *host_info_util.HostInfo, skipNotificationForThisPlugin ConnectionPlugin) error
	GetInitialConnectionHostInfo() *host_info_util.HostInfo
	GetCurrentHostInfo() (*host_info_util.HostInfo, error)
	GetAllHosts() []*host_info_util.HostInfo
	GetHosts() []*host_info_util.HostInfo
	SetAllowedAndBlockedHosts(allowedAndBlockedHosts *AllowedAndBlockedHosts)
	AcceptsStrategy(strategy string) bool
	GetHostInfoByStrategy(role host_info_util.HostRole, strategy string, hosts []*host_info_util.HostInfo) (*host_info_util.HostInfo, error)
	GetHostSelectorStrategy(strategy string) (hostSelector HostSelector, err error)
	GetHostRole(driver.Conn) host_info_util.HostRole
	SetAvailability(hostAliases map[string]bool, availability host_info_util.HostAvailability)
	IsInTransaction() bool
	SetInTransaction(inTransaction bool)
	GetCurrentTx() driver.Tx
	SetCurrentTx(driver.Tx)
	CreateHostListProvider(props *utils.RWMap[string, string]) HostListProvider
	SetHostListProvider(hostListProvider HostListProvider)
	SetInitialConnectionHostInfo(info *host_info_util.HostInfo)
	IsStaticHostListProvider() bool
	GetHostListProvider() HostListProvider
	RefreshHostList(conn driver.Conn) error
	ForceRefreshHostList(conn driver.Conn) error
	ForceRefreshHostListWithTimeout(shouldVerifyWriter bool, timeoutMs int) (bool, error)
	GetUpdatedHostListWithTimeout(shouldVerifyWriter bool, timeoutMs int) ([]*host_info_util.HostInfo, error)
	Connect(hostInfo *host_info_util.HostInfo, props *utils.RWMap[string, string], pluginToSkip ConnectionPlugin) (driver.Conn, error)
	ForceConnect(hostInfo *host_info_util.HostInfo, props *utils.RWMap[string, string]) (driver.Conn, error)
	GetDialect() DatabaseDialect
	SetDialect(dialect DatabaseDialect)
	UpdateDialect(conn driver.Conn)
	GetTargetDriverDialect() DriverDialect
	IdentifyConnection(conn driver.Conn) (*host_info_util.HostInfo, error)
	FillAliases(conn driver.Conn, hostInfo *host_info_util.HostInfo)
	GetConnectionProvider() ConnectionProvider
	GetProperties() *utils.RWMap[string, string]
	IsNetworkError(err error) bool
	IsLoginError(err error) bool
	GetTelemetryContext() context.Context
	GetTelemetryFactory() telemetry.TelemetryFactory
	SetTelemetryContext(ctx context.Context)
	UpdateState(sql string, methodArgs ...any)
	GetBgStatus(id string) (BlueGreenStatus, bool)
	SetBgStatus(status BlueGreenStatus, id string)
	IsPluginInUse(pluginName string) bool
	ResetSession()
}

type PluginServiceProvider

type PluginServiceProvider func(
	pluginManager PluginManager,
	driverDialect DriverDialect,
	props *utils.RWMap[string, string],
	dsn string) (PluginService, error)

type RandomHostSelector

type RandomHostSelector struct{}

func (*RandomHostSelector) GetHost

type RdsHostListProvider

type RdsHostListProvider struct {
	IsPrimaryClusterId bool
	// contains filtered or unexported fields
}

func NewRdsHostListProvider

func NewRdsHostListProvider(
	hostListProviderService HostListProviderService,
	databaseDialect TopologyAwareDialect,
	properties *utils.RWMap[string, string],
	queryForTopologyFunc func(conn driver.Conn) ([]*host_info_util.HostInfo, error),
	clusterIdChangedFunc func(oldClusterId string)) *RdsHostListProvider

func (*RdsHostListProvider) CreateHost

func (r *RdsHostListProvider) CreateHost(host string, hostRole host_info_util.HostRole, lag float64, cpu float64, lastUpdateTime time.Time) *host_info_util.HostInfo

func (*RdsHostListProvider) ForceRefresh

func (r *RdsHostListProvider) ForceRefresh(conn driver.Conn) ([]*host_info_util.HostInfo, error)

func (*RdsHostListProvider) GetClusterId

func (r *RdsHostListProvider) GetClusterId() (string, error)

func (*RdsHostListProvider) GetHostRole

func (r *RdsHostListProvider) GetHostRole(conn driver.Conn) host_info_util.HostRole

func (*RdsHostListProvider) IdentifyConnection

func (r *RdsHostListProvider) IdentifyConnection(conn driver.Conn) (*host_info_util.HostInfo, error)

func (*RdsHostListProvider) IsStaticHostListProvider

func (r *RdsHostListProvider) IsStaticHostListProvider() bool

func (*RdsHostListProvider) Refresh

type RdsMultiAzClusterMySQLDatabaseDialect added in v1.1.0

type RdsMultiAzClusterMySQLDatabaseDialect struct {
	MySQLTopologyAwareDatabaseDialect
}

func (*RdsMultiAzClusterMySQLDatabaseDialect) GetDialectUpdateCandidates added in v1.1.0

func (r *RdsMultiAzClusterMySQLDatabaseDialect) GetDialectUpdateCandidates() []string

func (*RdsMultiAzClusterMySQLDatabaseDialect) GetHostListProvider added in v1.1.0

func (r *RdsMultiAzClusterMySQLDatabaseDialect) GetHostListProvider(
	props *utils.RWMap[string, string],
	hostListProviderService HostListProviderService,
	pluginService PluginService) HostListProvider

func (*RdsMultiAzClusterMySQLDatabaseDialect) GetHostName added in v1.1.0

func (*RdsMultiAzClusterMySQLDatabaseDialect) GetTopology added in v1.1.0

func (*RdsMultiAzClusterMySQLDatabaseDialect) GetWriterHostName added in v1.1.0

func (r *RdsMultiAzClusterMySQLDatabaseDialect) GetWriterHostName(conn driver.Conn) (string, error)

func (*RdsMultiAzClusterMySQLDatabaseDialect) IsDialect added in v1.1.0

type RdsMultiAzClusterPgDatabaseDialect added in v1.1.0

type RdsMultiAzClusterPgDatabaseDialect struct {
	PgTopologyAwareDatabaseDialect
}

func (*RdsMultiAzClusterPgDatabaseDialect) GetDialectUpdateCandidates added in v1.1.0

func (r *RdsMultiAzClusterPgDatabaseDialect) GetDialectUpdateCandidates() []string

func (*RdsMultiAzClusterPgDatabaseDialect) GetHostListProvider added in v1.1.0

func (r *RdsMultiAzClusterPgDatabaseDialect) GetHostListProvider(
	props *utils.RWMap[string, string],
	hostListProviderService HostListProviderService,
	pluginService PluginService) HostListProvider

func (*RdsMultiAzClusterPgDatabaseDialect) GetHostName added in v1.1.0

func (*RdsMultiAzClusterPgDatabaseDialect) GetTopology added in v1.1.0

func (*RdsMultiAzClusterPgDatabaseDialect) GetWriterHostName added in v1.1.0

func (r *RdsMultiAzClusterPgDatabaseDialect) GetWriterHostName(conn driver.Conn) (string, error)

func (*RdsMultiAzClusterPgDatabaseDialect) IsDialect added in v1.1.0

type RdsMySQLDatabaseDialect

type RdsMySQLDatabaseDialect struct {
	MySQLDatabaseDialect
}

func (*RdsMySQLDatabaseDialect) GetBlueGreenStatus added in v1.1.0

func (m *RdsMySQLDatabaseDialect) GetBlueGreenStatus(conn driver.Conn) []BlueGreenResult

func (*RdsMySQLDatabaseDialect) GetDialectUpdateCandidates

func (m *RdsMySQLDatabaseDialect) GetDialectUpdateCandidates() []string

func (*RdsMySQLDatabaseDialect) IsBlueGreenStatusAvailable added in v1.1.0

func (m *RdsMySQLDatabaseDialect) IsBlueGreenStatusAvailable(conn driver.Conn) bool

func (*RdsMySQLDatabaseDialect) IsDialect

func (m *RdsMySQLDatabaseDialect) IsDialect(conn driver.Conn) bool

type RdsPgDatabaseDialect

type RdsPgDatabaseDialect struct {
	PgDatabaseDialect
}

func (*RdsPgDatabaseDialect) GetBlueGreenStatus added in v1.1.0

func (m *RdsPgDatabaseDialect) GetBlueGreenStatus(conn driver.Conn) []BlueGreenResult

func (*RdsPgDatabaseDialect) GetDialectUpdateCandidates

func (m *RdsPgDatabaseDialect) GetDialectUpdateCandidates() []string

func (*RdsPgDatabaseDialect) IsBlueGreenStatusAvailable added in v1.1.0

func (m *RdsPgDatabaseDialect) IsBlueGreenStatusAvailable(conn driver.Conn) bool

func (*RdsPgDatabaseDialect) IsDialect

func (m *RdsPgDatabaseDialect) IsDialect(conn driver.Conn) bool

type RoundRobinClusterInfo added in v1.1.0

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

type RoundRobinHostSelector added in v1.1.0

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

func GetRoundRobinHostSelector added in v1.1.0

func GetRoundRobinHostSelector() *RoundRobinHostSelector

GetRoundRobinHostSelector returns a shared instance of roundRobinHostSelector.

func (*RoundRobinHostSelector) ClearCache added in v1.1.0

func (r *RoundRobinHostSelector) ClearCache()

For testing purposes only.

func (*RoundRobinHostSelector) GetHost added in v1.1.0

type RoutingResultHolder added in v1.1.0

type RoutingResultHolder struct {
	WrappedReturnValue  any
	WrappedReturnValue2 any
	WrappedOk           bool
	WrappedErr          error
}

func (RoutingResultHolder) GetResult added in v1.1.0

func (r RoutingResultHolder) GetResult() (any, any, bool, error)

func (RoutingResultHolder) IsPresent added in v1.1.0

func (r RoutingResultHolder) IsPresent() bool

type SessionState

type SessionState struct {
	AutoCommit           SessionStateField[bool]
	ReadOnly             SessionStateField[bool]
	Catalog              SessionStateField[string]
	Schema               SessionStateField[string]
	TransactionIsolation SessionStateField[TransactionIsolationLevel]
}

func (*SessionState) Copy

func (ssf *SessionState) Copy() *SessionState

func (*SessionState) ToString

func (ssf *SessionState) ToString() string

type SessionStateField

type SessionStateField[T comparable] struct {
	// contains filtered or unexported fields
}

func (*SessionStateField[T]) CanRestorePristine

func (ssf *SessionStateField[T]) CanRestorePristine() bool

func (*SessionStateField[T]) GetPristineValue

func (ssf *SessionStateField[T]) GetPristineValue() *T

func (*SessionStateField[T]) GetValue

func (ssf *SessionStateField[T]) GetValue() *T

func (*SessionStateField[T]) Reset

func (ssf *SessionStateField[T]) Reset()

func (*SessionStateField[T]) ResetPristineValue

func (ssf *SessionStateField[T]) ResetPristineValue()

func (*SessionStateField[T]) ResetValue

func (ssf *SessionStateField[T]) ResetValue()

func (*SessionStateField[T]) SetPristineValue

func (ssf *SessionStateField[T]) SetPristineValue(value T)

func (*SessionStateField[T]) SetValue

func (ssf *SessionStateField[T]) SetValue(value T)

type SessionStateService

type SessionStateService interface {
	GetAutoCommit() *bool
	SetAutoCommit(bool)
	SetupPristineAutoCommit()
	SetupPristineAutoCommitWithVal(bool)

	GetReadOnly() *bool
	SetReadOnly(bool)
	SetupPristineReadOnly()
	SetupPristineReadOnlyWithVal(bool)

	GetCatalog() *string
	SetCatalog(string)
	SetupPristineCatalog()
	SetupPristineCatalogWithVal(string)

	GetSchema() *string
	SetSchema(string)
	SetupPristineSchema()
	SetupPristineSchemaWithVal(string)

	GetTransactionIsolation() *TransactionIsolationLevel
	SetTransactionIsolation(level TransactionIsolationLevel)
	SetupPristineTransactionIsolation()
	SetupPristineTransactionIsolationWithVal(TransactionIsolationLevel)

	Begin() error
	Complete()
	Reset()

	ApplyCurrentSessionState(conn driver.Conn) error
	ApplyPristineSessionState(conn driver.Conn) error
}

type SessionStateServiceImpl

type SessionStateServiceImpl struct {
	SessionState *SessionState
	// contains filtered or unexported fields
}

func NewSessionStateServiceImpl

func NewSessionStateServiceImpl(pluginService PluginService, props *utils.RWMap[string, string]) *SessionStateServiceImpl

func (*SessionStateServiceImpl) ApplyCurrentSessionState

func (sss *SessionStateServiceImpl) ApplyCurrentSessionState(newConn driver.Conn) error

func (*SessionStateServiceImpl) ApplyPristineSessionState

func (sss *SessionStateServiceImpl) ApplyPristineSessionState(conn driver.Conn) error

func (*SessionStateServiceImpl) Begin

func (sss *SessionStateServiceImpl) Begin() error

func (*SessionStateServiceImpl) Complete

func (sss *SessionStateServiceImpl) Complete()

func (*SessionStateServiceImpl) GetAutoCommit

func (sss *SessionStateServiceImpl) GetAutoCommit() *bool

func (*SessionStateServiceImpl) GetCatalog

func (sss *SessionStateServiceImpl) GetCatalog() *string

func (*SessionStateServiceImpl) GetReadOnly

func (sss *SessionStateServiceImpl) GetReadOnly() *bool

func (*SessionStateServiceImpl) GetSchema

func (sss *SessionStateServiceImpl) GetSchema() *string

func (*SessionStateServiceImpl) GetTransactionIsolation

func (sss *SessionStateServiceImpl) GetTransactionIsolation() *TransactionIsolationLevel

func (*SessionStateServiceImpl) Reset

func (sss *SessionStateServiceImpl) Reset()

func (*SessionStateServiceImpl) SetAutoCommit

func (sss *SessionStateServiceImpl) SetAutoCommit(val bool)

func (*SessionStateServiceImpl) SetCatalog

func (sss *SessionStateServiceImpl) SetCatalog(val string)

func (*SessionStateServiceImpl) SetReadOnly

func (sss *SessionStateServiceImpl) SetReadOnly(val bool)

func (*SessionStateServiceImpl) SetSchema

func (sss *SessionStateServiceImpl) SetSchema(val string)

func (*SessionStateServiceImpl) SetTransactionIsolation

func (sss *SessionStateServiceImpl) SetTransactionIsolation(val TransactionIsolationLevel)

func (*SessionStateServiceImpl) SetupPristineAutoCommit

func (sss *SessionStateServiceImpl) SetupPristineAutoCommit()

func (*SessionStateServiceImpl) SetupPristineAutoCommitWithVal

func (sss *SessionStateServiceImpl) SetupPristineAutoCommitWithVal(val bool)

func (*SessionStateServiceImpl) SetupPristineCatalog

func (sss *SessionStateServiceImpl) SetupPristineCatalog()

func (*SessionStateServiceImpl) SetupPristineCatalogWithVal

func (sss *SessionStateServiceImpl) SetupPristineCatalogWithVal(val string)

func (*SessionStateServiceImpl) SetupPristineReadOnly

func (sss *SessionStateServiceImpl) SetupPristineReadOnly()

func (*SessionStateServiceImpl) SetupPristineReadOnlyWithVal

func (sss *SessionStateServiceImpl) SetupPristineReadOnlyWithVal(val bool)

func (*SessionStateServiceImpl) SetupPristineSchema

func (sss *SessionStateServiceImpl) SetupPristineSchema()

func (*SessionStateServiceImpl) SetupPristineSchemaWithVal

func (sss *SessionStateServiceImpl) SetupPristineSchemaWithVal(val string)

func (*SessionStateServiceImpl) SetupPristineTransactionIsolation

func (sss *SessionStateServiceImpl) SetupPristineTransactionIsolation()

func (*SessionStateServiceImpl) SetupPristineTransactionIsolationWithVal

func (sss *SessionStateServiceImpl) SetupPristineTransactionIsolationWithVal(val TransactionIsolationLevel)

type TopologyAwareDialect

type TopologyAwareDialect interface {
	GetTopology(conn driver.Conn, provider HostListProvider) ([]*host_info_util.HostInfo, error)
	GetHostRole(conn driver.Conn) host_info_util.HostRole
	GetHostName(conn driver.Conn) string
	GetWriterHostName(conn driver.Conn) (string, error)
	DatabaseDialect
}

type TransactionIsolationLevel

type TransactionIsolationLevel int
const (
	TRANSACTION_READ_UNCOMMITTED TransactionIsolationLevel = 0
	TRANSACTION_READ_COMMITTED   TransactionIsolationLevel = 1
	TRANSACTION_REPEATABLE_READ  TransactionIsolationLevel = 2
	TRANSACTION_SERIALIZABLE     TransactionIsolationLevel = 3
)

type WeightedHostSelector

type WeightedHostSelector interface {
	SetHostWeights(hostWeightMap map[string]int)
	ClearHostWeights()
	HostSelector
}

type WeightedRandomHostSelector

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

func (*WeightedRandomHostSelector) ClearHostWeights

func (r *WeightedRandomHostSelector) ClearHostWeights()

func (*WeightedRandomHostSelector) GetHost

func (*WeightedRandomHostSelector) SetHostWeights

func (r *WeightedRandomHostSelector) SetHostWeights(hostWeightMap map[string]int)

func (*WeightedRandomHostSelector) SetRandomNumberFunc

func (r *WeightedRandomHostSelector) SetRandomNumberFunc(f func(int) int)

Jump to

Keyboard shortcuts

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