Documentation ¶
Index ¶
- type Config
- func (c *Config) GetDbName() string
- func (c *Config) GetDbType() string
- func (c *Config) GetDbUser() string
- func (c *Config) GetIsEnabled() bool
- func (c *Config) GetLogger() *loggerConfig.Config
- func (c *Config) GetOnConnectOptions() driver.ConfigOnConnectOptions
- func (c *Config) GetResolvers() []driver.Resolver
- func (c *Config) GetSearchForAnActiveResolverIfDownPolicy() driver.SearchForAnActiveResolverIfDownPolicy
- func (c *Config) GetSelf() driver.Config
- func (c *Config) GetSkipDefaultTransaction() bool
- type Connection
- type ConnectionPoolOptions
- type Credentials
- type CredentialsOverrides
- type DSN
- type OnConnectOptions
- type ReconnectOptions
- type Resolver
- func (r *Resolver) GetConnectionMaxIdleTimeSeconds() uint32
- func (r *Resolver) GetConnectionMaxLifeTimeSeconds() uint32
- func (r *Resolver) GetMaxIdleConnections() int
- func (r *Resolver) GetMaxOpenConnections() int
- func (r *Resolver) GetPolicyName() string
- func (r *Resolver) GetPolicyOptions() interface{}
- func (r *Resolver) GetReconnectOptions() driver.ReconnectOptions
- func (r *Resolver) GetReplicas() []driver.Connection
- func (r *Resolver) GetSources() []driver.Connection
- func (r *Resolver) GetTables() []string
- func (r *Resolver) SetPolicyOptions(policy interface{})
- type SearchForAnActiveResolverIfDownPolicy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { IsEnabled string `yaml:"is_enabled" mapstructure:"is_enabled" default:"yes"` Description string Credentials `yaml:"global_credentials" mapstructure:"global_credentials"` // These options should be on all connections! Charset string `yaml:"charset" mapstructure:"charset" default:"utf8mb4"` ParseTime string `yaml:"parse_time" mapstructure:"parse_time" default:"yes"` // GORM perform write (create/update/delete) operations run inside a transaction to ensure data consistency, which // is bad for performance, you can disable it during initialization SkipDefaultTransaction string `yaml:"skip_default_transaction" mapstructure:"skip_default_transaction" default:"no"` // These options are only for OnConnect event! OnConnectOptions OnConnectOptions `yaml:"on_connect_options" mapstructure:"on_connect_options"` // Here are the Connection Resolvers! // Define as many as you need, but usually you just need 1 (if you have a cluster) // a resolver can be as a Region Delimiter Resolvers []Resolver // Here we define reconnection things and other values SearchForAnActiveResolverIfDownPolicy `yaml:"search_for_an_active_resolver_if_down_policy" mapstructure:"search_for_an_active_resolver_if_down_policy"` // This is the logger configuration! Logger loggerConfig.Config }
func SetDefaults ¶
func (*Config) GetIsEnabled ¶
func (*Config) GetLogger ¶
func (c *Config) GetLogger() *loggerConfig.Config
func (*Config) GetOnConnectOptions ¶
func (c *Config) GetOnConnectOptions() driver.ConfigOnConnectOptions
func (*Config) GetResolvers ¶
func (*Config) GetSearchForAnActiveResolverIfDownPolicy ¶
func (c *Config) GetSearchForAnActiveResolverIfDownPolicy() driver.SearchForAnActiveResolverIfDownPolicy
func (*Config) GetSkipDefaultTransaction ¶
type Connection ¶
type Connection struct { // OverrideCredentials string `yaml:"override_credentials" mapstructure:"override_credentials" default:"no"` CredentialsOverrides CredentialsOverrides `yaml:"credentials_overrides" mapstructure:"credentials_overrides"` Credentials `yaml:"credentials" mapstructure:"credentials"` // This is only for this connection! ReconnectOptions `yaml:"reconnect_options" mapstructure:"reconnect_options"` // contains filtered or unexported fields }
func (*Connection) GenerateDSN ¶
func (c *Connection) GenerateDSN() DSN
func (*Connection) GetDialector ¶
func (c *Connection) GetDialector() gorm.Dialector
func (*Connection) GetReconnectOptions ¶
func (c *Connection) GetReconnectOptions() driver.ReconnectOptions
func (*Connection) SetLogger ¶
func (c *Connection) SetLogger(logger *model.Logger)
func (*Connection) SetMasterConfig ¶
func (c *Connection) SetMasterConfig(config interface{})
type ConnectionPoolOptions ¶
type ConnectionPoolOptions struct { // SetMaxIdleConnections sets the maximum number of connections in the idle connection pool. MaxIdleConnections int `yaml:"max_idle_connections" mapstructure:"max_idle_connections" default:"10"` // SetMaxOpenConnections sets the maximum number of open connections to the database. MaxOpenConnections int `yaml:"max_open_connections" mapstructure:"max_open_connections" default:"100"` // SetConnMaxLifetime sets the maximum amount of time a connection may be reused. ConnectionMaxLifeTimeSeconds uint32 `yaml:"connection_max_life_time_seconds" mapstructure:"connection_max_life_time_seconds" default:"86400"` ConnectionMaxIdleTimeSeconds uint32 `yaml:"connection_max_idle_time_seconds" mapstructure:"connection_max_idle_time_seconds" default:"3600"` }
type Credentials ¶
type Credentials struct { // Username,Password, DbName are the same for the entire cluster, but it depends if you are using some kind of // temporary password solution which changes every specific time... that's when you will need set the credentials // per host/node/server Host string `yaml:"host" mapstructure:"host" default:"localhost"` Port int `yaml:"port" mapstructure:"port" default:"3306"` User string `yaml:"user" mapstructure:"user" default:""` Password string `yaml:"password" mapstructure:"password" default:""` DbName string `yaml:"db_name" mapstructure:"db_name" default:""` }
type CredentialsOverrides ¶
type CredentialsOverrides struct { Host string `yaml:"host" mapstructure:"host" default:"no"` Port string `yaml:"port" mapstructure:"port" default:"no"` User string `yaml:"user" mapstructure:"user" default:"no"` Password string `yaml:"password" mapstructure:"password" default:"no"` DbName string `yaml:"db_name" mapstructure:"db_name" default:"no"` }
type OnConnectOptions ¶
type OnConnectOptions struct { RetryOnFailed string `yaml:"retry_on_failed" mapstructure:"retry_on_failed" default:"yes"` // -1 means -> infinite! by default it should not be infinite! The Client who send the request should handle // the query to retry if something!... This Retry only helps/saves from simple cases like internet connection failure // The DB Client should not retry till infinite, because it's not correct to save a query to memory or somewhere else // This is why, the logic part or the flow part should be on client side who makes the request MaxNrOfRetries int8 `yaml:"retry_times_on_failed" mapstructure:"retry_times_on_failed" default:"3"` // This is the delay between Total retries RetryDelaySeconds int8 `yaml:"retry_delay_seconds" mapstructure:"retry_delay_seconds" default:"2"` // Delay between connections, usually it's 0, because we don't need any delay between different connections // we need them to connect as fast as possible! OnFailedDelayDurationBetweenConnections time.Duration `yaml:"on_failed_delay_duration_between_connections" mapstructure:"on_failed_delay_duration_between_connections" default:"0"` PanicOnFailed string `yaml:"panic_on_failed" mapstructure:"panic_on_failed" default:"no"` }
func (*OnConnectOptions) GetMaxNrOfRetries ¶
func (o *OnConnectOptions) GetMaxNrOfRetries() int8
func (*OnConnectOptions) GetOnFailedDelayDurationBetweenConnections ¶
func (o *OnConnectOptions) GetOnFailedDelayDurationBetweenConnections() time.Duration
func (*OnConnectOptions) GetPanicOnFailed ¶
func (o *OnConnectOptions) GetPanicOnFailed() bool
func (*OnConnectOptions) GetRetryDelaySeconds ¶
func (o *OnConnectOptions) GetRetryDelaySeconds() int8
func (*OnConnectOptions) GetRetryOnFailed ¶
func (o *OnConnectOptions) GetRetryOnFailed() bool
type ReconnectOptions ¶
type ReconnectOptions struct { IsEnabled string `yaml:"is_enabled" mapstructure:"is_enabled" default:"yes"` // ReconnectAfterSeconds -> 5 Seconds, after disconnect happened, the client will reconnect after // indicated time! ReconnectAfterSeconds uint16 `yaml:"reconnect_after_seconds" mapstructure:"reconnect_after_seconds" default:"5"` // MaxRetries -> -1 -> infinite! Maximum nr of retries.... MaxRetries int16 `yaml:"max_retries" mapstructure:"max_retries" default:"3"` }
func (*ReconnectOptions) GetIsEnabled ¶
func (r *ReconnectOptions) GetIsEnabled() bool
func (*ReconnectOptions) GetMaxRetries ¶
func (r *ReconnectOptions) GetMaxRetries() int16
func (*ReconnectOptions) GetReconnectAfterSeconds ¶
func (r *ReconnectOptions) GetReconnectAfterSeconds() uint16
type Resolver ¶
type Resolver struct { // if it's not working (depending on the policy type and algo of selection) // it will go to next one...if none of them working it will start from beginning or it will trigger // an error...? we should define how many times or how much time it will check for the connections to be ok PolicyName string `yaml:"policy_name" mapstructure:"policy_name" default:"round_robin"` //PolicyOptions PolicyOptions `yaml:"policy_options" mapstructure:"policy_options"` // PolicyOptions should not be exported to yaml // It should be used only internal as code... PolicyOptions dbresolver.Policy `yaml:"-"` ReconnectOptions `yaml:"reconnect_options" mapstructure:"reconnect_options"` // For which tables it's referred to...it will switch automatically the connections based on this // Is using this, the Root Resolver will switch/use the resolver based on this Tables []string ConnectionPoolOptions `yaml:"connection_pool_options" mapstructure:"connection_pool_options"` // When writing or read writing it will always take the connections from here... Sources []Connection // When only reading, it will always take the connections from here! Replicas []Connection }
Multiple resolvers should be used on your own risk...
func (*Resolver) GetConnectionMaxIdleTimeSeconds ¶
func (*Resolver) GetConnectionMaxLifeTimeSeconds ¶
func (*Resolver) GetMaxIdleConnections ¶
func (*Resolver) GetMaxOpenConnections ¶
func (*Resolver) GetPolicyName ¶
func (*Resolver) GetPolicyOptions ¶
func (r *Resolver) GetPolicyOptions() interface{}
func (r *Resolver) GetPolicyOptions() dbresolver.Policy {
func (*Resolver) GetReconnectOptions ¶
func (r *Resolver) GetReconnectOptions() driver.ReconnectOptions
func (*Resolver) GetReplicas ¶
func (r *Resolver) GetReplicas() []driver.Connection
func (*Resolver) GetSources ¶
func (r *Resolver) GetSources() []driver.Connection
func (*Resolver) SetPolicyOptions ¶
func (r *Resolver) SetPolicyOptions(policy interface{})
func (r *Resolver) SetPolicyOptions(policy dbresolver.Policy) {
type SearchForAnActiveResolverIfDownPolicy ¶
type SearchForAnActiveResolverIfDownPolicy struct { IsEnabled string `yaml:"is_enabled" mapstructure:"is_enabled" default:"yes"` // DelayMsBetweenSearches uint16 `yaml:"delay_ms_between_searches" mapstructure:"delay_ms_between_searches" default:"2000"` // MaxRetries -> -1 -> infinite! Maximum nr of retries.... MaxRetries int16 `yaml:"max_retries" mapstructure:"max_retries" default:"3"` }
func (*SearchForAnActiveResolverIfDownPolicy) GetDelayMsBetweenSearches ¶
func (s *SearchForAnActiveResolverIfDownPolicy) GetDelayMsBetweenSearches() uint16
func (*SearchForAnActiveResolverIfDownPolicy) GetIsEnabled ¶
func (s *SearchForAnActiveResolverIfDownPolicy) GetIsEnabled() bool
func (*SearchForAnActiveResolverIfDownPolicy) GetMaxRetries ¶
func (s *SearchForAnActiveResolverIfDownPolicy) GetMaxRetries() int16
Click to show internal directories.
Click to hide internal directories.