Documentation ¶
Index ¶
- Constants
- func Use(str string) clause.Interface
- type Config
- type DBResolver
- func (dr *DBResolver) Call(fc func(connPool gorm.ConnPool) error) error
- func (dr *DBResolver) Initialize(db *gorm.DB) error
- func (dr *DBResolver) IsTerminating() bool
- func (dr *DBResolver) LDebug() *zerolog.Event
- func (dr *DBResolver) LDebugF(functionName string) *zerolog.Event
- func (dr *DBResolver) LError() *zerolog.Event
- func (dr *DBResolver) LErrorF(functionName string) *zerolog.Event
- func (dr *DBResolver) LEvent(eventType string, eventName string, beforeMsg func(event *zerolog.Event))
- func (dr *DBResolver) LEventCustom(eventType string, eventName string) *zerolog.Event
- func (dr *DBResolver) LEventF(eventType string, eventName string, functionName string) *zerolog.Event
- func (dr *DBResolver) LFatal() *zerolog.Event
- func (dr *DBResolver) LInfo() *zerolog.Event
- func (dr *DBResolver) LInfoF(functionName string) *zerolog.Event
- func (dr *DBResolver) LPanic() *zerolog.Event
- func (dr *DBResolver) LWarn() *zerolog.Event
- func (dr *DBResolver) LWarnF(functionName string) *zerolog.Event
- func (dr *DBResolver) Name() string
- func (dr *DBResolver) Register(config Config, datas ...interface{}) (*DBResolver, error)
- func (dr *DBResolver) SetConnMaxIdleTime(d time.Duration) *DBResolver
- func (dr *DBResolver) SetConnMaxLifetime(d time.Duration) *DBResolver
- func (dr *DBResolver) SetMainConfig(config driver.Config)
- func (dr *DBResolver) SetMaxIdleConns(n int) *DBResolver
- func (dr *DBResolver) SetMaxOpenConns(n int) *DBResolver
- type Operation
- type PConsecutive
- type PLoadBalancing
- type PRandom
- type PRoundRobin
- type Policy
- type PolicyCommon
- func (p *PolicyCommon) GetConnPools() []detailedConnPool
- func (p *PolicyCommon) GetContext() context.Context
- func (p *PolicyCommon) GetNrOfConns() int
- func (p *PolicyCommon) LDebugF(functionName string) *zerolog.Event
- func (p *PolicyCommon) LErrorF(functionName string) *zerolog.Event
- func (p *PolicyCommon) LInfoF(functionName string) *zerolog.Event
- func (p *PolicyCommon) LWarnF(functionName string) *zerolog.Event
- type PolicyPingOptions
- func (p *PolicyPingOptions) GetIsPingRetryEnabled() bool
- func (p *PolicyPingOptions) GetPingRetryDelaySeconds() uint16
- func (p *PolicyPingOptions) GetPingRetryTimes() int16
- func (p *PolicyPingOptions) SetIsPingRetryEnabled(isEnabled bool)
- func (p *PolicyPingOptions) SetPingRetryDelaySeconds(delaySeconds uint16)
- func (p *PolicyPingOptions) SetPingRetryTimes(retryTimes int16)
Constants ¶
const ResolverAllNodesOffline = 1
const ResolverReadOnly = 3
const ResolverReadyToProcess = 2
const ResolverStartingUp = 3
const TConsecutive = "consecutive"
const TLoadBalancing = "load_balancing"
const TRandom = "random"
const TRoundRobin = "round_robin"
Letter "T" it's
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DBResolver ¶
type DBResolver struct { *gorm.DB // Logger Logger *model.Logger // contains filtered or unexported fields }
func New ¶
func New() *DBResolver
func Register ¶
func Register( config Config, datas ...interface{}, ) (*DBResolver, error)
func (*DBResolver) Initialize ¶
func (dr *DBResolver) Initialize(db *gorm.DB) error
Initialize this is how gorm initializes our code...
func (*DBResolver) IsTerminating ¶
func (dr *DBResolver) IsTerminating() bool
func (*DBResolver) LDebugF ¶
func (dr *DBResolver) LDebugF(functionName string) *zerolog.Event
LDebugF -> when you need specifically to indicate in what function the logging is happening
func (*DBResolver) LErrorF ¶
func (dr *DBResolver) LErrorF(functionName string) *zerolog.Event
LErrorF -> when you need specifically to indicate in what function the logging is happening
func (*DBResolver) LEvent ¶
func (dr *DBResolver) LEvent(eventType string, eventName string, beforeMsg func(event *zerolog.Event))
func (*DBResolver) LEventCustom ¶
func (dr *DBResolver) LEventCustom(eventType string, eventName string) *zerolog.Event
func (*DBResolver) LInfoF ¶
func (dr *DBResolver) LInfoF(functionName string) *zerolog.Event
LInfoF -> when you need specifically to indicate in what function the logging is happening
func (*DBResolver) LWarnF ¶
func (dr *DBResolver) LWarnF(functionName string) *zerolog.Event
LWarnF -> when you need specifically to indicate in what function the logging is happening
func (*DBResolver) Name ¶
func (dr *DBResolver) Name() string
func (*DBResolver) Register ¶
func (dr *DBResolver) Register( config Config, datas ...interface{}, ) (*DBResolver, error)
func (*DBResolver) SetConnMaxIdleTime ¶
func (dr *DBResolver) SetConnMaxIdleTime(d time.Duration) *DBResolver
func (*DBResolver) SetConnMaxLifetime ¶
func (dr *DBResolver) SetConnMaxLifetime(d time.Duration) *DBResolver
func (*DBResolver) SetMainConfig ¶
func (dr *DBResolver) SetMainConfig(config driver.Config)
func (*DBResolver) SetMaxIdleConns ¶
func (dr *DBResolver) SetMaxIdleConns(n int) *DBResolver
func (*DBResolver) SetMaxOpenConns ¶
func (dr *DBResolver) SetMaxOpenConns(n int) *DBResolver
type PConsecutive ¶
type PConsecutive struct { PolicyPingOptions PolicyCommon }
func (*PConsecutive) Resolve ¶
func (p *PConsecutive) Resolve(resolverOptions *resolveOptions) gorm.ConnPool
type PLoadBalancing ¶
type PLoadBalancing struct { PolicyPingOptions PolicyCommon }
It's hard to know how to spread the traffic evenly, for that we need traffic analysis by communicating directly with the servers... or cluster TODO: We should know in % how busy is a node... TODO: for that we should have instances that are connected with the nodes, and which will read the % very often...
func (*PLoadBalancing) Resolve ¶
func (p *PLoadBalancing) Resolve(resolverOptions *resolveOptions) gorm.ConnPool
type PRandom ¶
type PRandom struct { PolicyPingOptions PolicyCommon // contains filtered or unexported fields }
type PRoundRobin ¶
type PRoundRobin struct { PolicyPingOptions PolicyCommon // contains filtered or unexported fields }
func NewRoundRobinPolicy ¶
func NewRoundRobinPolicy() (*PRoundRobin, error)
func (*PRoundRobin) GetConnID ¶
func (p *PRoundRobin) GetConnID() int
GetConnID -> Get's the connection id from the stack based on the policy
func (*PRoundRobin) Resolve ¶
func (p *PRoundRobin) Resolve(resolverOptions *resolveOptions) gorm.ConnPool
Resolve -> get the connection based on the current policy
type PolicyCommon ¶
type PolicyCommon struct {
// contains filtered or unexported fields
}
func (*PolicyCommon) GetConnPools ¶
func (p *PolicyCommon) GetConnPools() []detailedConnPool
GetConnPools -> get all connections
func (*PolicyCommon) GetContext ¶
func (p *PolicyCommon) GetContext() context.Context
func (*PolicyCommon) GetNrOfConns ¶
func (p *PolicyCommon) GetNrOfConns() int
type PolicyPingOptions ¶
type PolicyPingOptions struct { IsPingRetryEnabled string `default:"yes"` PingRetryTimes int16 `default:"3"` PingRetryDelaySeconds uint16 `default:"5"` }
func (*PolicyPingOptions) GetIsPingRetryEnabled ¶
func (p *PolicyPingOptions) GetIsPingRetryEnabled() bool
func (*PolicyPingOptions) GetPingRetryDelaySeconds ¶
func (p *PolicyPingOptions) GetPingRetryDelaySeconds() uint16
GetPingRetryDelaySeconds -> when checking if connection is alive, this is the delay between rechecks
func (*PolicyPingOptions) GetPingRetryTimes ¶
func (p *PolicyPingOptions) GetPingRetryTimes() int16
GetPingRetryTimes -> how many times it should retry the ping...
func (*PolicyPingOptions) SetIsPingRetryEnabled ¶
func (p *PolicyPingOptions) SetIsPingRetryEnabled(isEnabled bool)
func (*PolicyPingOptions) SetPingRetryDelaySeconds ¶
func (p *PolicyPingOptions) SetPingRetryDelaySeconds(delaySeconds uint16)
func (*PolicyPingOptions) SetPingRetryTimes ¶
func (p *PolicyPingOptions) SetPingRetryTimes(retryTimes int16)
Source Files ¶
- callbacks.go
- clauses.go
- database.go
- dbresolver.go
- dbresolver_compile.go
- dbresolver_convertor.go
- dbresolver_functions.go
- dbresolver_logger.go
- dbresolver_model.go
- dbresolver_monitoring.go
- dbresolver_pool_availability.go
- dbresolver_register.go
- dbresolver_resolve.go
- helpers.go
- policy.go
- policy_check_connection.go
- policy_common.go
- policy_consecutive.go
- policy_load_balancing.go
- policy_ping_options.go
- policy_random.go
- policy_round_robin.go
- policy_types.go
- resolve_options.go
- resolver.go
- resolver_abilities.go
- resolver_connections_monitoring.go
- resolver_functions.go
- resolver_logging.go
- resolver_model.go
- utils.go