Documentation
¶
Index ¶
- Constants
- Variables
- func AllKeys[T comparable, V any](mapOfKeysAndValues map[T]V) []T
- func CheckIdpCredentialsWithFallback(idpUserNameProperty property_util.AwsWrapperProperty, ...)
- func CombineMaps[K comparable, V any](mapToCopy map[K]V, mapToAdd map[K]V) map[K]V
- func ConvertDriverValueToString(value driver.Value) (string, bool)
- func CreateMapCopy[K comparable, V any](mapToCopy map[K]V) map[K]V
- func DoesCloseTransaction(methodName string, methodArgs ...any) bool
- func DoesOpenTransaction(methodName string, methodArgs ...any) bool
- func ExecQueryDirectly(conn driver.Conn, query string) error
- func FilterSlice[T any](slice []T, filter func(T) bool) []T
- func FindHostInTopology(hosts []*host_info_util.HostInfo, hostNames ...string) *host_info_util.HostInfo
- func FindRegisteredDriver(dialectCode string) bool
- func GetFirstRowFromQuery(conn driver.Conn, query string) []driver.Value
- func GetFirstRowFromQueryAsString(conn driver.Conn, query string) []string
- func GetHostNameFromEndpoint(endpoint string) string
- func GetHostsFromDsn(dsn string, isSingleWriterDsn bool) (hostInfoList []*host_info_util.HostInfo, err error)
- func GetPreparedHost(host string) string
- func GetProtocol(dsn string) (string, error)
- func GetQueryFromSqlOrMethodArgs(sql string, methodArgs ...any) string
- func GetRdsClusterHostUrl(host string) string
- func GetRdsInstanceHostPattern(host string) string
- func GetRdsRegion(host string) string
- func GetSeparateSqlStatements(query string) []string
- func GetStructName(v any) string
- func IndexOf[T any](slice []T, item T, compareFunc func(T, T) bool) int
- func IsIPV6(host string) bool
- func IsIPv4(host string) bool
- func IsLimitlessDbShardGroupDns(host string) bool
- func IsRdsClusterDns(host string) bool
- func IsRdsCustomClusterDns(host string) bool
- func IsRdsDns(host string) bool
- func IsRdsProxyDns(host string) bool
- func IsReachable(conn driver.Conn, ctx context.Context) bool
- func IsReaderClusterDns(host string) bool
- func IsWriterClusterDns(host string) bool
- func LengthOfSyncMap(syncMap *sync.Map) int
- func LogTopology(hosts []*host_info_util.HostInfo, msgPrefix string) string
- func MaskProperties(props map[string]string) map[string]string
- func MaskSensitiveInfoFromDsn(dsn string) string
- func ParseDatabaseFromDsn(dsn string) (string, error)
- func ParseDsn(dsn string) (map[string]string, error)
- func ParseHostPortPair(instanceClusterTemplate string, defaultPort int) (*host_info_util.HostInfo, error)
- func ParsePasswordFromDsn(dsn string) (string, error)
- func ParseUserFromDsn(dsn string) (string, error)
- func RemoveFromSlice[T any](slice []T, item T, compareFunc func(T, T) bool) []T
- func ResetPreparedHostFunc()
- func Rollback(conn driver.Conn, currentTx driver.Tx)
- func SetPreparedHostFunc(newPrepareHostFunc func(string) string)
- func SliceAndMapHaveCommonElement[T comparable, V any](sliceA []T, mapOfKeysAndValues map[T]V) bool
- func ValidateUrl(url string) error
- type CacheMap
- func (c *CacheMap[T]) CleanUp()
- func (c *CacheMap[T]) Clear()
- func (c *CacheMap[T]) ComputeIfAbsent(key string, computeFunc func() T, itemExpiration time.Duration) T
- func (c *CacheMap[T]) Get(key string) (T, bool)
- func (c *CacheMap[T]) GetAllEntries() map[string]T
- func (c *CacheMap[T]) Put(key string, value T, expiration time.Duration)
- func (c *CacheMap[T]) PutIfAbsent(key string, value T, expiration time.Duration)
- func (c *CacheMap[T]) Remove(key string)
- func (c *CacheMap[T]) Size() int
- type DisposalFunc
- type RdsUrlType
- type SlidingExpirationCache
- func (c *SlidingExpirationCache[T]) CleanUp()
- func (c *SlidingExpirationCache[T]) Clear()
- func (c *SlidingExpirationCache[T]) ComputeIfAbsent(key string, computeFunc func() T, itemExpiration time.Duration) T
- func (c *SlidingExpirationCache[T]) Get(key string, itemExpiration time.Duration) (T, bool)
- func (c *SlidingExpirationCache[T]) GetAllEntries() map[string]T
- func (c *SlidingExpirationCache[T]) Put(key string, value T, itemExpiration time.Duration)
- func (c *SlidingExpirationCache[T]) PutIfAbsent(key string, value T, expiration time.Duration)
- func (c *SlidingExpirationCache[T]) Remove(key string)
- func (c *SlidingExpirationCache[T]) SetCleanupIntervalNanos(newIntervalNanos time.Duration)
- func (c *SlidingExpirationCache[T]) Size() int
Constants ¶
View Source
const ( PGX_DRIVER_PROTOCOL = "postgresql" MYSQL_DRIVER_PROTOCOL = "mysql" NET_PROP_KEY = "net" )
View Source
const ( CONN_PREPARE = "Conn.Prepare" CONN_PREPARE_CONTEXT = "Conn.PrepareContext" CONN_CLOSE = "Conn.Close" CONN_BEGIN = "Conn.Begin" CONN_BEGIN_TX = "Conn.BeginTx" CONN_QUERY_CONTEXT = "Conn.QueryContext" CONN_EXEC_CONTEXT = "Conn.ExecContext" CONN_PING = "Conn.Ping" CONN_IS_VALID = "Conn.IsValid" CONN_RESET_SESSION = "Conn.ResetSession" CONN_CHECK_NAMED_VALUE = "Conn.CheckNamedValue" STMT_CLOSE = "Stmt.Close" STMT_EXEC = "Stmt.Exec" STMT_EXEC_CONTEXT = "Stmt.ExecContext" STMT_NUM_INPUT = "Stmt.NumInput" STMT_QUERY = "Stmt.Query" STMT_QUERY_CONTEXT = "Stmt.QueryContext" STMT_CHECK_NAMED_VALUE = "Stmt.CheckNamedValue" RESULT_LAST_INSERT_ID = "Result.LastInsertId" RESULT_ROWS_AFFECTED = "Result.RowsAffected" TX_COMMIT = "Tx.Commit" TX_ROLLBACK = "Tx.Rollback" ROWS_CLOSE = "Rows.Close" ROWS_COLUMNS = "Rows.Columns" ROWS_NEXT = "Rows.Next" ROWS_COLUMN_TYPE_PRECISION_SCALE = "Rows.ColumnTypePrecisionScale" ROWS_COLUMN_TYPE_DATABASE_TYPE_NAME = "Rows.ColumnTypeDatabaseTypeName" ROWS_COLUMN_TYPE_LENGTH = "Rows.ColumnTypeLength" ROWS_HAS_NEXT_RESULT_SET = "Rows.HasNextResultSet" ROWS_NEXT_RESULT_SET = "Rows.NextResultSet" ROWS_COLUMN_TYPE_SCAN_TYPE = "Rows.ColumnTypeScanType" ROWS_COLUMN_TYPE_NULLABLE = "Rows.ColumnTypeNullable" )
View Source
const ( INSTANCE_GROUP = "instance" DNS_GROUP = "dns" DOMAIN_GROUP = "domain" REGION_GROUP = "region" )
View Source
const SET_AUTOCOMMIT_0 = "set autocommit = 0"
Variables ¶
View Source
var ( AURORA_DNS_PATTERN = regexp.MustCompile( "(?i)^(?P<instance>.+)\\." + "(?P<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|shardgrp-)?" + "(?P<domain>[a-zA-Z0-9]+\\.(?P<region>[a-zA-Z0-9\\-]+)" + "\\.rds\\.amazonaws\\.com\\.?)$") AURORA_CHINA_DNS_PATTERN = regexp.MustCompile( "(?i)^(?P<instance>.+)\\." + "(?P<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|shardgrp-)?" + "(?P<domain>[a-zA-Z0-9]+\\.rds\\.(?P<region>[a-zA-Z0-9\\-]+)" + "\\.amazonaws\\.com\\.cn\\.?)$") AURORA_OLD_CHINA_DNS_PATTERN = regexp.MustCompile( "(?i)^(?P<instance>.+)\\." + "(?P<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|shardgrp-)?" + "(?P<domain>[a-zA-Z0-9]+\\.(?P<region>[a-zA-Z0-9\\-]+)" + "\\.rds\\.amazonaws\\.com\\.cn\\.?)$") AURORA_GOV_DNS_PATTERN = regexp.MustCompile( "(?i)^(?<instance>.+)\\." + "(?P<dns>proxy-|cluster-|cluster-ro-|cluster-custom-|shardgrp-)?" + "(?P<domain>[a-zA-Z0-9]+\\.rds\\.(?P<region>[a-zA-Z0-9\\-]+)" + "\\.(amazonaws\\.com\\.?|c2s\\.ic\\.gov\\.?|sc2s\\.sgov\\.gov\\.?))$") IP_V4_REGEXP = regexp.MustCompile( "^(([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){1}" + "(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){2}" + "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$") IP_V6_REGEXP = regexp.MustCompile("^[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){7}$") IP_V6_COMPRESSED_REGEXP = regexp.MustCompile("^(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)" + "::(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)$") )
View Source
var CLOSING_METHODS = []string{ CONN_CLOSE, CONN_IS_VALID, STMT_CLOSE, ROWS_CLOSE, }
View Source
var CleanupIntervalNanos time.Duration = 10 * time.Minute
View Source
var NETWORK_BOUND_METHODS = []string{ CONN_PREPARE, CONN_PREPARE_CONTEXT, CONN_QUERY_CONTEXT, CONN_EXEC_CONTEXT, CONN_PING, CONN_IS_VALID, CONN_RESET_SESSION, STMT_EXEC, STMT_EXEC_CONTEXT, STMT_QUERY, STMT_QUERY_CONTEXT, TX_COMMIT, TX_ROLLBACK, ROWS_NEXT, ROWS_HAS_NEXT_RESULT_SET, ROWS_NEXT_RESULT_SET, }
View Source
var REQUIRED_METHODS = []string{ CONN_PREPARE, CONN_PREPARE_CONTEXT, CONN_CLOSE, CONN_BEGIN, CONN_BEGIN_TX, CONN_QUERY_CONTEXT, CONN_EXEC_CONTEXT, CONN_PING, CONN_IS_VALID, CONN_RESET_SESSION, CONN_CHECK_NAMED_VALUE, STMT_CLOSE, STMT_EXEC, STMT_EXEC_CONTEXT, STMT_NUM_INPUT, STMT_QUERY, STMT_QUERY_CONTEXT, STMT_CHECK_NAMED_VALUE, RESULT_LAST_INSERT_ID, RESULT_ROWS_AFFECTED, TX_COMMIT, TX_ROLLBACK, ROWS_CLOSE, ROWS_COLUMNS, ROWS_NEXT, ROWS_COLUMN_TYPE_PRECISION_SCALE, ROWS_COLUMN_TYPE_DATABASE_TYPE_NAME, }
View Source
var SENSITIVE_PROPERTIES = map[string]struct{}{ property_util.PASSWORD.Name: {}, property_util.IDP_PASSWORD.Name: {}, }
Functions ¶
func AllKeys ¶
func AllKeys[T comparable, V any](mapOfKeysAndValues map[T]V) []T
func CheckIdpCredentialsWithFallback ¶
func CheckIdpCredentialsWithFallback( idpUserNameProperty property_util.AwsWrapperProperty, idpPasswordProperty property_util.AwsWrapperProperty, props map[string]string)
func CombineMaps ¶
func CombineMaps[K comparable, V any](mapToCopy map[K]V, mapToAdd map[K]V) map[K]V
func CreateMapCopy ¶
func CreateMapCopy[K comparable, V any](mapToCopy map[K]V) map[K]V
func DoesCloseTransaction ¶
func DoesOpenTransaction ¶
func FilterSlice ¶
func FindHostInTopology ¶
func FindHostInTopology(hosts []*host_info_util.HostInfo, hostNames ...string) *host_info_util.HostInfo
func FindRegisteredDriver ¶
func GetFirstRowFromQuery ¶
Directly executes query on conn, and returns the first row. Returns nil if unable to obtain a row.
func GetFirstRowFromQueryAsString ¶
Directly executes query on conn and converts all possible values in the first row to strings. Any values that cannot be converted are returned as "". Returns nil if unable to obtain a row.
func GetHostNameFromEndpoint ¶
func GetHostsFromDsn ¶
func GetHostsFromDsn(dsn string, isSingleWriterDsn bool) (hostInfoList []*host_info_util.HostInfo, err error)
func GetPreparedHost ¶
func GetProtocol ¶
func GetRdsClusterHostUrl ¶
func GetRdsRegion ¶
func GetStructName ¶
func IsRdsClusterDns ¶
func IsRdsCustomClusterDns ¶
func IsRdsProxyDns ¶
func IsReaderClusterDns ¶
func IsWriterClusterDns ¶
func LengthOfSyncMap ¶
func LogTopology ¶
func LogTopology(hosts []*host_info_util.HostInfo, msgPrefix string) string
func ParseDatabaseFromDsn ¶
func ParseHostPortPair ¶
func ParseHostPortPair(instanceClusterTemplate string, defaultPort int) (*host_info_util.HostInfo, error)
func ParsePasswordFromDsn ¶
func ParseUserFromDsn ¶
func RemoveFromSlice ¶
func ResetPreparedHostFunc ¶
func ResetPreparedHostFunc()
func SetPreparedHostFunc ¶
func SliceAndMapHaveCommonElement ¶
func SliceAndMapHaveCommonElement[T comparable, V any](sliceA []T, mapOfKeysAndValues map[T]V) bool
func ValidateUrl ¶
Types ¶
type CacheMap ¶
type CacheMap[T any] struct { // contains filtered or unexported fields }
func (*CacheMap[T]) ComputeIfAbsent ¶
func (*CacheMap[T]) GetAllEntries ¶
Get a map copy of all entries in the cache, including expired entries.
func (*CacheMap[T]) PutIfAbsent ¶
type DisposalFunc ¶
type RdsUrlType ¶
var ( OTHER RdsUrlType = RdsUrlType{0, false, false} RDS_WRITER_CLUSTER RdsUrlType = RdsUrlType{1, true, true} RDS_READER_CLUSTER RdsUrlType = RdsUrlType{2, true, true} RDS_CUSTOM_CLUSTER RdsUrlType = RdsUrlType{3, true, true} RDS_PROXY RdsUrlType = RdsUrlType{4, true, false} RDS_INSTANCE RdsUrlType = RdsUrlType{5, true, false} RDS_AURORA_LIMITLESS_DB_SHARD_GROUP RdsUrlType = RdsUrlType{6, true, false} IP_ADDRESS RdsUrlType = RdsUrlType{7, false, false} )
func IdentifyRdsUrlType ¶
func IdentifyRdsUrlType(host string) RdsUrlType
type SlidingExpirationCache ¶
type SlidingExpirationCache[T any] struct { // contains filtered or unexported fields }
func NewSlidingExpirationCache ¶
func NewSlidingExpirationCache[T any](id string, funcs ...DisposalFunc[T]) *SlidingExpirationCache[T]
func (*SlidingExpirationCache[T]) CleanUp ¶
func (c *SlidingExpirationCache[T]) CleanUp()
func (*SlidingExpirationCache[T]) Clear ¶
func (c *SlidingExpirationCache[T]) Clear()
func (*SlidingExpirationCache[T]) ComputeIfAbsent ¶
func (c *SlidingExpirationCache[T]) ComputeIfAbsent(key string, computeFunc func() T, itemExpiration time.Duration) T
func (*SlidingExpirationCache[T]) Get ¶
func (c *SlidingExpirationCache[T]) Get(key string, itemExpiration time.Duration) (T, bool)
func (*SlidingExpirationCache[T]) GetAllEntries ¶
func (c *SlidingExpirationCache[T]) GetAllEntries() map[string]T
Get a map copy of all entries in the cache, including expired entries.
func (*SlidingExpirationCache[T]) Put ¶
func (c *SlidingExpirationCache[T]) Put(key string, value T, itemExpiration time.Duration)
func (*SlidingExpirationCache[T]) PutIfAbsent ¶
func (c *SlidingExpirationCache[T]) PutIfAbsent(key string, value T, expiration time.Duration)
func (*SlidingExpirationCache[T]) Remove ¶
func (c *SlidingExpirationCache[T]) Remove(key string)
func (*SlidingExpirationCache[T]) SetCleanupIntervalNanos ¶
func (c *SlidingExpirationCache[T]) SetCleanupIntervalNanos(newIntervalNanos time.Duration)
func (*SlidingExpirationCache[T]) Size ¶
func (c *SlidingExpirationCache[T]) Size() int
Source Files
¶
Click to show internal directories.
Click to hide internal directories.