Documentation
¶
Index ¶
- Variables
- func InitActiveRecord(opts ...Option)
- func Logger() logger.LoggerInterface
- func NewDefaultConfig() func(ctx context.Context) ConfigInterface
- func ReinitActiveRecord(opts ...Option)
- func WithShard(masters []OptionInterface, replicas []OptionInterface) clusterOption
- type ARMertics
- type ARMetricCount
- type ARMetricTimer
- type ActiveRecord
- type BaseConnectionOptions
- type BaseField
- type Cluster
- func AddClusterChecker(ctx context.Context, configPath string, params ClusterConfigParameters) (*Cluster, error)
- func GetClusterInfoFromCfg(ctx context.Context, path string, globs MapGlobParam, ...) (*Cluster, error)
- func NewCluster(shardCnt int) *Cluster
- func NewClusterInfo(opts ...clusterOption) *Cluster
- func (c *Cluster) Append(shard Shard)
- func (c *Cluster) Equal(c2 *Cluster) bool
- func (c *Cluster) NextMaster(shardNum int) ShardInstance
- func (c *Cluster) NextReplica(shardNum int) (ShardInstance, bool)
- func (c *Cluster) SetShardInstances(shardNum int, instances []ShardInstance)
- func (c *Cluster) ShardInstances(shardNum int) []ShardInstance
- func (c *Cluster) Shards() int
- type ClusterCheckerInterface
- type ClusterConfigParameters
- type ConfigCacherInterface
- type ConfigInterface
- type ConnectionCacherInterface
- type ConnectionInterface
- type CumulativeMetricsInterface
- type DefaultConfig
- func (dc *DefaultConfig) GetBool(confPath string, dfl ...bool) (bool, error)
- func (dc *DefaultConfig) GetBoolIfExists(confPath string) (value bool, ok bool, err error)
- func (dc *DefaultConfig) GetDuration(confPath string, dfl ...time.Duration) (time.Duration, error)
- func (dc *DefaultConfig) GetDurationIfExists(confPath string) (time.Duration, bool, error)
- func (dc *DefaultConfig) GetInt(confPath string, dfl ...int64) (int64, error)
- func (dc *DefaultConfig) GetIntIfExists(confPath string) (int64, bool, error)
- func (dc *DefaultConfig) GetLastUpdateTime() time.Time
- func (dc *DefaultConfig) GetString(confPath string, dfl ...string) (string, error)
- func (dc *DefaultConfig) GetStringIfExists(confPath string) (string, bool, error)
- func (dc *DefaultConfig) GetStrings(confPath string, dfl []string) ([]string, error)
- func (dc *DefaultConfig) GetStruct(confPath string, valuePtr interface{}) (bool, error)
- type DefaultConfigCacher
- type DefaultNoopMetric
- type DefaultNoopMetricCount
- type DefaultNoopMetricTimer
- type Limiter
- type MapGlobParam
- type MetricErrorCountInterface
- type MetricInterface
- type MetricStatCountInterface
- type MetricTimerInterface
- type MockConfig
- func (_m *MockConfig) EXPECT() *MockConfig_Expecter
- func (_m *MockConfig) GetBool(confPath string, dfl ...bool) (bool, error)
- func (_m *MockConfig) GetBoolIfExists(confPath string) (bool, bool, error)
- func (_m *MockConfig) GetDuration(confPath string, dfl ...time.Duration) (time.Duration, error)
- func (_m *MockConfig) GetDurationIfExists(confPath string) (time.Duration, bool, error)
- func (_m *MockConfig) GetInt(confPath string, dfl ...int64) (int64, error)
- func (_m *MockConfig) GetIntIfExists(confPath string) (int64, bool, error)
- func (_m *MockConfig) GetString(confPath string, dfl ...string) (string, error)
- func (_m *MockConfig) GetStringIfExists(confPath string) (string, bool, error)
- func (_m *MockConfig) GetStrings(confPath string, dfl []string) ([]string, error)
- func (_m *MockConfig) GetStruct(confPath string, valuePtr interface{}) (bool, error)
- type MockConfig_Expecter
- func (_e *MockConfig_Expecter) GetBool(confPath interface{}, dfl ...interface{}) *MockConfig_GetBool_Call
- func (_e *MockConfig_Expecter) GetBoolIfExists(confPath interface{}) *MockConfig_GetBoolIfExists_Call
- func (_e *MockConfig_Expecter) GetDuration(confPath interface{}, dfl ...interface{}) *MockConfig_GetDuration_Call
- func (_e *MockConfig_Expecter) GetDurationIfExists(confPath interface{}) *MockConfig_GetDurationIfExists_Call
- func (_e *MockConfig_Expecter) GetInt(confPath interface{}, dfl ...interface{}) *MockConfig_GetInt_Call
- func (_e *MockConfig_Expecter) GetIntIfExists(confPath interface{}) *MockConfig_GetIntIfExists_Call
- func (_e *MockConfig_Expecter) GetString(confPath interface{}, dfl ...interface{}) *MockConfig_GetString_Call
- func (_e *MockConfig_Expecter) GetStringIfExists(confPath interface{}) *MockConfig_GetStringIfExists_Call
- func (_e *MockConfig_Expecter) GetStrings(confPath interface{}, dfl interface{}) *MockConfig_GetStrings_Call
- func (_e *MockConfig_Expecter) GetStruct(confPath interface{}, valuePtr interface{}) *MockConfig_GetStruct_Call
- type MockConfig_GetBoolIfExists_Call
- func (_c *MockConfig_GetBoolIfExists_Call) Return(value bool, ok bool, err error) *MockConfig_GetBoolIfExists_Call
- func (_c *MockConfig_GetBoolIfExists_Call) Run(run func(confPath string)) *MockConfig_GetBoolIfExists_Call
- func (_c *MockConfig_GetBoolIfExists_Call) RunAndReturn(run func(string) (bool, bool, error)) *MockConfig_GetBoolIfExists_Call
- type MockConfig_GetBool_Call
- func (_c *MockConfig_GetBool_Call) Return(_a0 bool, _a1 error) *MockConfig_GetBool_Call
- func (_c *MockConfig_GetBool_Call) Run(run func(confPath string, dfl ...bool)) *MockConfig_GetBool_Call
- func (_c *MockConfig_GetBool_Call) RunAndReturn(run func(string, ...bool) (bool, error)) *MockConfig_GetBool_Call
- type MockConfig_GetDurationIfExists_Call
- func (_c *MockConfig_GetDurationIfExists_Call) Return(_a0 time.Duration, _a1 bool, _a2 error) *MockConfig_GetDurationIfExists_Call
- func (_c *MockConfig_GetDurationIfExists_Call) Run(run func(confPath string)) *MockConfig_GetDurationIfExists_Call
- func (_c *MockConfig_GetDurationIfExists_Call) RunAndReturn(run func(string) (time.Duration, bool, error)) *MockConfig_GetDurationIfExists_Call
- type MockConfig_GetDuration_Call
- func (_c *MockConfig_GetDuration_Call) Return(_a0 time.Duration, _a1 error) *MockConfig_GetDuration_Call
- func (_c *MockConfig_GetDuration_Call) Run(run func(confPath string, dfl ...time.Duration)) *MockConfig_GetDuration_Call
- func (_c *MockConfig_GetDuration_Call) RunAndReturn(run func(string, ...time.Duration) (time.Duration, error)) *MockConfig_GetDuration_Call
- type MockConfig_GetIntIfExists_Call
- func (_c *MockConfig_GetIntIfExists_Call) Return(_a0 int64, _a1 bool, _a2 error) *MockConfig_GetIntIfExists_Call
- func (_c *MockConfig_GetIntIfExists_Call) Run(run func(confPath string)) *MockConfig_GetIntIfExists_Call
- func (_c *MockConfig_GetIntIfExists_Call) RunAndReturn(run func(string) (int64, bool, error)) *MockConfig_GetIntIfExists_Call
- type MockConfig_GetInt_Call
- func (_c *MockConfig_GetInt_Call) Return(_a0 int64, _a1 error) *MockConfig_GetInt_Call
- func (_c *MockConfig_GetInt_Call) Run(run func(confPath string, dfl ...int64)) *MockConfig_GetInt_Call
- func (_c *MockConfig_GetInt_Call) RunAndReturn(run func(string, ...int64) (int64, error)) *MockConfig_GetInt_Call
- type MockConfig_GetStringIfExists_Call
- func (_c *MockConfig_GetStringIfExists_Call) Return(_a0 string, _a1 bool, _a2 error) *MockConfig_GetStringIfExists_Call
- func (_c *MockConfig_GetStringIfExists_Call) Run(run func(confPath string)) *MockConfig_GetStringIfExists_Call
- func (_c *MockConfig_GetStringIfExists_Call) RunAndReturn(run func(string) (string, bool, error)) *MockConfig_GetStringIfExists_Call
- type MockConfig_GetString_Call
- func (_c *MockConfig_GetString_Call) Return(_a0 string, _a1 error) *MockConfig_GetString_Call
- func (_c *MockConfig_GetString_Call) Run(run func(confPath string, dfl ...string)) *MockConfig_GetString_Call
- func (_c *MockConfig_GetString_Call) RunAndReturn(run func(string, ...string) (string, error)) *MockConfig_GetString_Call
- type MockConfig_GetStrings_Call
- func (_c *MockConfig_GetStrings_Call) Return(_a0 []string, _a1 error) *MockConfig_GetStrings_Call
- func (_c *MockConfig_GetStrings_Call) Run(run func(confPath string, dfl []string)) *MockConfig_GetStrings_Call
- func (_c *MockConfig_GetStrings_Call) RunAndReturn(run func(string, []string) ([]string, error)) *MockConfig_GetStrings_Call
- type MockConfig_GetStruct_Call
- func (_c *MockConfig_GetStruct_Call) Return(_a0 bool, _a1 error) *MockConfig_GetStruct_Call
- func (_c *MockConfig_GetStruct_Call) Run(run func(confPath string, valuePtr interface{})) *MockConfig_GetStruct_Call
- func (_c *MockConfig_GetStruct_Call) RunAndReturn(run func(string, interface{}) (bool, error)) *MockConfig_GetStruct_Call
- type ModelStruct
- type OpCode
- type Option
- func WithConfig(config func(ctx context.Context) ConfigInterface) Option
- func WithConfigCacher(configCacher ConfigCacherInterface) Option
- func WithConnectionPinger(pc ClusterCheckerInterface) Option
- func WithLogger(logger logger.LoggerInterface) Option
- func WithMetrics(metric MetricInterface) Option
- type OptionInterface
- type SelectorLimiter
- type SerializerInterface
- type ServerModeType
- type Shard
- type ShardInstance
- type ShardInstanceConfig
- type ShardInstanceType
Constants ¶
This section is empty.
Variables ¶
var ErrNoData = errors.New("no data")
Functions ¶
func InitActiveRecord ¶
func InitActiveRecord(opts ...Option)
func Logger ¶
func Logger() logger.LoggerInterface
func NewDefaultConfig ¶
func NewDefaultConfig() func(ctx context.Context) ConfigInterface
func ReinitActiveRecord ¶
func ReinitActiveRecord(opts ...Option)
func WithShard ¶
func WithShard(masters []OptionInterface, replicas []OptionInterface) clusterOption
Types ¶
type ARMertics ¶
type ARMertics struct {
// contains filtered or unexported fields
}
func NewARMetrics ¶
func NewARMetrics(metrics *prometheus.Registry, cumulativeMetrics CumulativeMetricsInterface) *ARMertics
func (*ARMertics) ErrorCount ¶
func (m *ARMertics) ErrorCount(storage, entity string) MetricStatCountInterface
func (*ARMertics) StatCount ¶
func (m *ARMertics) StatCount(storage, entity string) MetricStatCountInterface
func (*ARMertics) Timer ¶
func (m *ARMertics) Timer(storage, entity string) MetricTimerInterface
type ARMetricCount ¶
type ARMetricCount struct {
// contains filtered or unexported fields
}
type ARMetricTimer ¶
type ARMetricTimer struct {
// contains filtered or unexported fields
}
type ActiveRecord ¶
type ActiveRecord struct {
// contains filtered or unexported fields
}
func GetInstance ¶
func GetInstance() *ActiveRecord
type BaseConnectionOptions ¶
type BaseConnectionOptions struct { Mode ServerModeType ConnectionHash hash.Hash32 Calculated bool }
BaseConnectionOptions - опции используемые для подключения
func (*BaseConnectionOptions) GetConnectionID ¶
func (o *BaseConnectionOptions) GetConnectionID() string
GetConnectionID - получение ConnecitionID. После первого получения, больше нельзя его модифицировать. Можно только новый Options создать
func (*BaseConnectionOptions) InstanceMode ¶
func (o *BaseConnectionOptions) InstanceMode() ServerModeType
InstanceMode - метод для получения режима работы инстанса RO или RW
func (*BaseConnectionOptions) UpdateHash ¶
func (o *BaseConnectionOptions) UpdateHash(data ...interface{}) error
UpdateHash - функция расчета ConnectionID, необходима для шаринга конектов между моделями.
type BaseField ¶
type BaseField struct { Collection []ModelStruct Objects map[string][]ModelStruct Exists bool ShardNum uint32 IsReplica bool Readonly bool }
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Тип описывающий кластер. Сейчас кластер - это набор шардов.
func AddClusterChecker ¶
func AddClusterChecker(ctx context.Context, configPath string, params ClusterConfigParameters) (*Cluster, error)
AddClusterChecker регистрирует конфигурацию кластера в локальном пингере
func GetClusterInfoFromCfg ¶
func GetClusterInfoFromCfg(ctx context.Context, path string, globs MapGlobParam, optionCreator func(ShardInstanceConfig) (OptionInterface, error)) (*Cluster, error)
Констркуктор позволяющий проинициализировать кластер их конфигурации. На вход передаётся путь в конфиге, значения по умолчанию, и ссылка на функцию, которая создаёт структуру опций и считает контрольную сумму, для того, что бы следить за их изменением в онлайне.
func NewCluster ¶
func NewClusterInfo ¶
func NewClusterInfo(opts ...clusterOption) *Cluster
Конструктор который позволяет проинициализировать новый кластер. В опциях передаются все шарды, сколько шардов, столько и опций. Используется в случаях, когда информация по кластеру прописана непосредственно в декларации модели, а не в конфиге. Так же используется при тестировании.
func (*Cluster) Equal ¶
Equal сравнивает загруженные конфигурации кластеров на основе контрольной суммы всех инстансов кластера
func (*Cluster) NextMaster ¶
func (c *Cluster) NextMaster(shardNum int) ShardInstance
NextMaster выбирает следующий доступный инстанс мастера в шарде shardNum
func (*Cluster) NextReplica ¶
func (c *Cluster) NextReplica(shardNum int) (ShardInstance, bool)
NextMaster выбирает следующий доступный инстанс реплики в шарде shardNum
func (*Cluster) SetShardInstances ¶
func (c *Cluster) SetShardInstances(shardNum int, instances []ShardInstance)
SetShardInstances заменяет инстансы кластера в шарде shardNum на инстансы из instances
func (*Cluster) ShardInstances ¶
func (c *Cluster) ShardInstances(shardNum int) []ShardInstance
ShardInstances копия всех инстансов из шарды shardNum
type ClusterCheckerInterface ¶
type ClusterConfigParameters ¶
type ClusterConfigParameters struct { Globs MapGlobParam OptionCreator func(ShardInstanceConfig) (OptionInterface, error) OptionChecker func(ctx context.Context, instance ShardInstance) (OptionInterface, error) }
func (ClusterConfigParameters) Validate ¶
func (c ClusterConfigParameters) Validate() bool
type ConfigCacherInterface ¶
type ConfigCacherInterface interface {
Get(ctx context.Context, path string, glob MapGlobParam, optionCreator func(ShardInstanceConfig) (OptionInterface, error)) (*Cluster, error)
}
func ConfigCacher ¶
func ConfigCacher() ConfigCacherInterface
type ConfigInterface ¶
type ConfigInterface interface { GetBool(confPath string, dfl ...bool) (bool, error) GetBoolIfExists(confPath string) (value bool, ok bool, err error) GetInt(confPath string, dfl ...int64) (int64, error) GetIntIfExists(confPath string) (int64, bool, error) GetDuration(confPath string, dfl ...time.Duration) (time.Duration, error) GetDurationIfExists(confPath string) (time.Duration, bool, error) GetString(confPath string, dfl ...string) (string, error) GetStringIfExists(confPath string) (string, bool, error) GetStrings(confPath string, dfl []string) ([]string, error) GetStruct(confPath string, valuePtr interface{}) (bool, error) }
func Config ¶
func Config(ctx context.Context) ConfigInterface
type ConnectionCacherInterface ¶
type ConnectionCacherInterface interface { Add(shard ShardInstance, connector func(interface{}) (ConnectionInterface, error)) (ConnectionInterface, error) GetOrAdd(shard ShardInstance, connector func(interface{}) (ConnectionInterface, error)) (ConnectionInterface, error) Get(shard ShardInstance) ConnectionInterface CloseConnection(context.Context) }
func ConnectionCacher ¶
func ConnectionCacher() ConnectionCacherInterface
type ConnectionInterface ¶
type ConnectionInterface interface { Close() Done() <-chan struct{} }
func GetConnection ¶
func GetConnection( ctx context.Context, configPath string, globParam MapGlobParam, optionCreator func(ShardInstanceConfig) (OptionInterface, error), instType ShardInstanceType, shard int, getConnection func(options interface{}) (ConnectionInterface, error), ) (ConnectionInterface, error)
TODO - сделать статистику по используемым инстансам - прикрутить локальный пингер и исключать недоступные инстансы
type DefaultConfig ¶
type DefaultConfig struct {
// contains filtered or unexported fields
}
func NewDefaultConfigFromMap ¶
func NewDefaultConfigFromMap(cfg map[string]interface{}) *DefaultConfig
func (*DefaultConfig) GetBool ¶
func (dc *DefaultConfig) GetBool(confPath string, dfl ...bool) (bool, error)
func (*DefaultConfig) GetBoolIfExists ¶
func (dc *DefaultConfig) GetBoolIfExists(confPath string) (value bool, ok bool, err error)
func (*DefaultConfig) GetDuration ¶
func (*DefaultConfig) GetDurationIfExists ¶
func (*DefaultConfig) GetInt ¶
func (dc *DefaultConfig) GetInt(confPath string, dfl ...int64) (int64, error)
func (*DefaultConfig) GetIntIfExists ¶
func (dc *DefaultConfig) GetIntIfExists(confPath string) (int64, bool, error)
func (*DefaultConfig) GetLastUpdateTime ¶
func (dc *DefaultConfig) GetLastUpdateTime() time.Time
func (*DefaultConfig) GetString ¶
func (dc *DefaultConfig) GetString(confPath string, dfl ...string) (string, error)
func (*DefaultConfig) GetStringIfExists ¶
func (dc *DefaultConfig) GetStringIfExists(confPath string) (string, bool, error)
func (*DefaultConfig) GetStrings ¶
func (dc *DefaultConfig) GetStrings(confPath string, dfl []string) ([]string, error)
type DefaultConfigCacher ¶
type DefaultConfigCacher struct {
// contains filtered or unexported fields
}
Структура для кеширования полученных конфигураций. Инвалидация происходит посредством сравнения updateTime сданной труктуры и самого конфига. Используется для шаринга конфигов между можелями если они используют одну и ту же конфигурацию для подключений
func NewConfigCacher ¶
func NewConfigCacher() *DefaultConfigCacher
Конструктор для создания нового кешера конфигов
func (*DefaultConfigCacher) Get ¶
func (cc *DefaultConfigCacher) Get(ctx context.Context, path string, globs MapGlobParam, optionCreator func(ShardInstanceConfig) (OptionInterface, error)) (*Cluster, error)
Получение конфигурации. Если есть в кеше и он еще валидный, то конфигурация берётся из кеша если в кеше нет, то достаём из конфига и кешируем.
type DefaultNoopMetric ¶
type DefaultNoopMetric struct{}
func NewDefaultNoopMetric ¶
func NewDefaultNoopMetric() *DefaultNoopMetric
func (*DefaultNoopMetric) ErrorCount ¶
func (*DefaultNoopMetric) ErrorCount(storage, entity string) MetricStatCountInterface
func (*DefaultNoopMetric) StatCount ¶
func (*DefaultNoopMetric) StatCount(storage, entity string) MetricStatCountInterface
func (*DefaultNoopMetric) Timer ¶
func (*DefaultNoopMetric) Timer(storage, entity string) MetricTimerInterface
type DefaultNoopMetricCount ¶
type DefaultNoopMetricCount struct{}
type DefaultNoopMetricTimer ¶
type DefaultNoopMetricTimer struct{}
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
func EmptyLimiter ¶
func EmptyLimiter() Limiter
func NewLimitOffset ¶
func NewLimiter ¶
func NewThreshold ¶
func (Limiter) FulfillWarn ¶
type MapGlobParam ¶
Тип используемый для передачи набора значений по умолчанию для параметров
type MetricInterface ¶
type MetricInterface interface { StatCount(storage, entity string) MetricStatCountInterface ErrorCount(storage, entity string) MetricStatCountInterface Timer(storage, entity string) MetricTimerInterface }
func Metric ¶
func Metric() MetricInterface
type MetricTimerInterface ¶
type MockConfig ¶
MockConfig is an autogenerated mock type for the ConfigInterface type
func NewMockConfig ¶
func NewMockConfig(t interface { mock.TestingT Cleanup(func()) }) *MockConfig
NewMockConfig creates a new instance of MockConfig. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockConfig) EXPECT ¶
func (_m *MockConfig) EXPECT() *MockConfig_Expecter
func (*MockConfig) GetBool ¶
func (_m *MockConfig) GetBool(confPath string, dfl ...bool) (bool, error)
GetBool provides a mock function with given fields: confPath, dfl
func (*MockConfig) GetBoolIfExists ¶
func (_m *MockConfig) GetBoolIfExists(confPath string) (bool, bool, error)
GetBoolIfExists provides a mock function with given fields: confPath
func (*MockConfig) GetDuration ¶
GetDuration provides a mock function with given fields: confPath, dfl
func (*MockConfig) GetDurationIfExists ¶
GetDurationIfExists provides a mock function with given fields: confPath
func (*MockConfig) GetInt ¶
func (_m *MockConfig) GetInt(confPath string, dfl ...int64) (int64, error)
GetInt provides a mock function with given fields: confPath, dfl
func (*MockConfig) GetIntIfExists ¶
func (_m *MockConfig) GetIntIfExists(confPath string) (int64, bool, error)
GetIntIfExists provides a mock function with given fields: confPath
func (*MockConfig) GetString ¶
func (_m *MockConfig) GetString(confPath string, dfl ...string) (string, error)
GetString provides a mock function with given fields: confPath, dfl
func (*MockConfig) GetStringIfExists ¶
func (_m *MockConfig) GetStringIfExists(confPath string) (string, bool, error)
GetStringIfExists provides a mock function with given fields: confPath
func (*MockConfig) GetStrings ¶
func (_m *MockConfig) GetStrings(confPath string, dfl []string) ([]string, error)
GetStrings provides a mock function with given fields: confPath, dfl
type MockConfig_Expecter ¶
type MockConfig_Expecter struct {
// contains filtered or unexported fields
}
func (*MockConfig_Expecter) GetBool ¶
func (_e *MockConfig_Expecter) GetBool(confPath interface{}, dfl ...interface{}) *MockConfig_GetBool_Call
GetBool is a helper method to define mock.On call
- confPath string
- dfl ...bool
func (*MockConfig_Expecter) GetBoolIfExists ¶
func (_e *MockConfig_Expecter) GetBoolIfExists(confPath interface{}) *MockConfig_GetBoolIfExists_Call
GetBoolIfExists is a helper method to define mock.On call
- confPath string
func (*MockConfig_Expecter) GetDuration ¶
func (_e *MockConfig_Expecter) GetDuration(confPath interface{}, dfl ...interface{}) *MockConfig_GetDuration_Call
GetDuration is a helper method to define mock.On call
- confPath string
- dfl ...time.Duration
func (*MockConfig_Expecter) GetDurationIfExists ¶
func (_e *MockConfig_Expecter) GetDurationIfExists(confPath interface{}) *MockConfig_GetDurationIfExists_Call
GetDurationIfExists is a helper method to define mock.On call
- confPath string
func (*MockConfig_Expecter) GetInt ¶
func (_e *MockConfig_Expecter) GetInt(confPath interface{}, dfl ...interface{}) *MockConfig_GetInt_Call
GetInt is a helper method to define mock.On call
- confPath string
- dfl ...int64
func (*MockConfig_Expecter) GetIntIfExists ¶
func (_e *MockConfig_Expecter) GetIntIfExists(confPath interface{}) *MockConfig_GetIntIfExists_Call
GetIntIfExists is a helper method to define mock.On call
- confPath string
func (*MockConfig_Expecter) GetString ¶
func (_e *MockConfig_Expecter) GetString(confPath interface{}, dfl ...interface{}) *MockConfig_GetString_Call
GetString is a helper method to define mock.On call
- confPath string
- dfl ...string
func (*MockConfig_Expecter) GetStringIfExists ¶
func (_e *MockConfig_Expecter) GetStringIfExists(confPath interface{}) *MockConfig_GetStringIfExists_Call
GetStringIfExists is a helper method to define mock.On call
- confPath string
func (*MockConfig_Expecter) GetStrings ¶
func (_e *MockConfig_Expecter) GetStrings(confPath interface{}, dfl interface{}) *MockConfig_GetStrings_Call
GetStrings is a helper method to define mock.On call
- confPath string
- dfl []string
func (*MockConfig_Expecter) GetStruct ¶
func (_e *MockConfig_Expecter) GetStruct(confPath interface{}, valuePtr interface{}) *MockConfig_GetStruct_Call
GetStruct is a helper method to define mock.On call
- confPath string
- valuePtr interface{}
type MockConfig_GetBoolIfExists_Call ¶
MockConfig_GetBoolIfExists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetBoolIfExists'
func (*MockConfig_GetBoolIfExists_Call) Return ¶
func (_c *MockConfig_GetBoolIfExists_Call) Return(value bool, ok bool, err error) *MockConfig_GetBoolIfExists_Call
func (*MockConfig_GetBoolIfExists_Call) Run ¶
func (_c *MockConfig_GetBoolIfExists_Call) Run(run func(confPath string)) *MockConfig_GetBoolIfExists_Call
func (*MockConfig_GetBoolIfExists_Call) RunAndReturn ¶
func (_c *MockConfig_GetBoolIfExists_Call) RunAndReturn(run func(string) (bool, bool, error)) *MockConfig_GetBoolIfExists_Call
type MockConfig_GetBool_Call ¶
MockConfig_GetBool_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetBool'
func (*MockConfig_GetBool_Call) Return ¶
func (_c *MockConfig_GetBool_Call) Return(_a0 bool, _a1 error) *MockConfig_GetBool_Call
func (*MockConfig_GetBool_Call) Run ¶
func (_c *MockConfig_GetBool_Call) Run(run func(confPath string, dfl ...bool)) *MockConfig_GetBool_Call
func (*MockConfig_GetBool_Call) RunAndReturn ¶
func (_c *MockConfig_GetBool_Call) RunAndReturn(run func(string, ...bool) (bool, error)) *MockConfig_GetBool_Call
type MockConfig_GetDurationIfExists_Call ¶
MockConfig_GetDurationIfExists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDurationIfExists'
func (*MockConfig_GetDurationIfExists_Call) Return ¶
func (_c *MockConfig_GetDurationIfExists_Call) Return(_a0 time.Duration, _a1 bool, _a2 error) *MockConfig_GetDurationIfExists_Call
func (*MockConfig_GetDurationIfExists_Call) Run ¶
func (_c *MockConfig_GetDurationIfExists_Call) Run(run func(confPath string)) *MockConfig_GetDurationIfExists_Call
func (*MockConfig_GetDurationIfExists_Call) RunAndReturn ¶
func (_c *MockConfig_GetDurationIfExists_Call) RunAndReturn(run func(string) (time.Duration, bool, error)) *MockConfig_GetDurationIfExists_Call
type MockConfig_GetDuration_Call ¶
MockConfig_GetDuration_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDuration'
func (*MockConfig_GetDuration_Call) Return ¶
func (_c *MockConfig_GetDuration_Call) Return(_a0 time.Duration, _a1 error) *MockConfig_GetDuration_Call
func (*MockConfig_GetDuration_Call) Run ¶
func (_c *MockConfig_GetDuration_Call) Run(run func(confPath string, dfl ...time.Duration)) *MockConfig_GetDuration_Call
func (*MockConfig_GetDuration_Call) RunAndReturn ¶
func (_c *MockConfig_GetDuration_Call) RunAndReturn(run func(string, ...time.Duration) (time.Duration, error)) *MockConfig_GetDuration_Call
type MockConfig_GetIntIfExists_Call ¶
MockConfig_GetIntIfExists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetIntIfExists'
func (*MockConfig_GetIntIfExists_Call) Return ¶
func (_c *MockConfig_GetIntIfExists_Call) Return(_a0 int64, _a1 bool, _a2 error) *MockConfig_GetIntIfExists_Call
func (*MockConfig_GetIntIfExists_Call) Run ¶
func (_c *MockConfig_GetIntIfExists_Call) Run(run func(confPath string)) *MockConfig_GetIntIfExists_Call
func (*MockConfig_GetIntIfExists_Call) RunAndReturn ¶
func (_c *MockConfig_GetIntIfExists_Call) RunAndReturn(run func(string) (int64, bool, error)) *MockConfig_GetIntIfExists_Call
type MockConfig_GetInt_Call ¶
MockConfig_GetInt_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetInt'
func (*MockConfig_GetInt_Call) Return ¶
func (_c *MockConfig_GetInt_Call) Return(_a0 int64, _a1 error) *MockConfig_GetInt_Call
func (*MockConfig_GetInt_Call) Run ¶
func (_c *MockConfig_GetInt_Call) Run(run func(confPath string, dfl ...int64)) *MockConfig_GetInt_Call
func (*MockConfig_GetInt_Call) RunAndReturn ¶
func (_c *MockConfig_GetInt_Call) RunAndReturn(run func(string, ...int64) (int64, error)) *MockConfig_GetInt_Call
type MockConfig_GetStringIfExists_Call ¶
MockConfig_GetStringIfExists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetStringIfExists'
func (*MockConfig_GetStringIfExists_Call) Return ¶
func (_c *MockConfig_GetStringIfExists_Call) Return(_a0 string, _a1 bool, _a2 error) *MockConfig_GetStringIfExists_Call
func (*MockConfig_GetStringIfExists_Call) Run ¶
func (_c *MockConfig_GetStringIfExists_Call) Run(run func(confPath string)) *MockConfig_GetStringIfExists_Call
func (*MockConfig_GetStringIfExists_Call) RunAndReturn ¶
func (_c *MockConfig_GetStringIfExists_Call) RunAndReturn(run func(string) (string, bool, error)) *MockConfig_GetStringIfExists_Call
type MockConfig_GetString_Call ¶
MockConfig_GetString_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetString'
func (*MockConfig_GetString_Call) Return ¶
func (_c *MockConfig_GetString_Call) Return(_a0 string, _a1 error) *MockConfig_GetString_Call
func (*MockConfig_GetString_Call) Run ¶
func (_c *MockConfig_GetString_Call) Run(run func(confPath string, dfl ...string)) *MockConfig_GetString_Call
func (*MockConfig_GetString_Call) RunAndReturn ¶
func (_c *MockConfig_GetString_Call) RunAndReturn(run func(string, ...string) (string, error)) *MockConfig_GetString_Call
type MockConfig_GetStrings_Call ¶
MockConfig_GetStrings_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetStrings'
func (*MockConfig_GetStrings_Call) Return ¶
func (_c *MockConfig_GetStrings_Call) Return(_a0 []string, _a1 error) *MockConfig_GetStrings_Call
func (*MockConfig_GetStrings_Call) Run ¶
func (_c *MockConfig_GetStrings_Call) Run(run func(confPath string, dfl []string)) *MockConfig_GetStrings_Call
func (*MockConfig_GetStrings_Call) RunAndReturn ¶
func (_c *MockConfig_GetStrings_Call) RunAndReturn(run func(string, []string) ([]string, error)) *MockConfig_GetStrings_Call
type MockConfig_GetStruct_Call ¶
MockConfig_GetStruct_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetStruct'
func (*MockConfig_GetStruct_Call) Return ¶
func (_c *MockConfig_GetStruct_Call) Return(_a0 bool, _a1 error) *MockConfig_GetStruct_Call
func (*MockConfig_GetStruct_Call) Run ¶
func (_c *MockConfig_GetStruct_Call) Run(run func(confPath string, valuePtr interface{})) *MockConfig_GetStruct_Call
func (*MockConfig_GetStruct_Call) RunAndReturn ¶
func (_c *MockConfig_GetStruct_Call) RunAndReturn(run func(string, interface{}) (bool, error)) *MockConfig_GetStruct_Call
type ModelStruct ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func WithConfig ¶
func WithConfig(config func(ctx context.Context) ConfigInterface) Option
func WithConfigCacher ¶
func WithConfigCacher(configCacher ConfigCacherInterface) Option
func WithConnectionPinger ¶
func WithConnectionPinger(pc ClusterCheckerInterface) Option
func WithLogger ¶
func WithLogger(logger logger.LoggerInterface) Option
func WithMetrics ¶
func WithMetrics(metric MetricInterface) Option
type OptionInterface ¶
type OptionInterface interface { GetConnectionID() string InstanceMode() ServerModeType }
Интерфейс которому должен соответствовать билдер опций подключения к конретному инстансу
type SelectorLimiter ¶
type SerializerInterface ¶
type ServerModeType ¶
type ServerModeType uint8
Тип и константы для определения режима работы конкретного инстанса.
const ( ModeMaster ServerModeType = iota ModeReplica )
type Shard ¶
type Shard struct { Masters []ShardInstance Replicas []ShardInstance // contains filtered or unexported fields }
Структура описывающая конкретный шард. Каждый шард может состоять из набора мастеров и реплик
func (*Shard) Instances ¶
func (c *Shard) Instances() []ShardInstance
Instances копия списка конфигураций всех инстансов шарды. В начале списка следуют мастера, потом реплики
func (*Shard) NextMaster ¶
func (s *Shard) NextMaster() ShardInstance
Функция выбирающая следующий доступный инстанс мастера в конкретном шарде
func (*Shard) NextReplica ¶
func (s *Shard) NextReplica() ShardInstance
Инстанс выбирающий следующий доступный инстанс реплики в конкретном шарде
type ShardInstance ¶
type ShardInstance struct { ParamsID string Config ShardInstanceConfig Options interface{} Offline bool }
Структура описывающая инстанс в кластере
type ShardInstanceConfig ¶
type ShardInstanceConfig struct { Timeout time.Duration Mode ServerModeType PoolSize int32 Addr string User string Password string Port uint16 DB string }
Структура используется для описания конфигурации конктретного инстанса
type ShardInstanceType ¶
type ShardInstanceType uint8
Тип и константы для выбора инстанса в шарде
const ( MasterInstanceType ShardInstanceType = iota // Любой из описанных мастеров. По умолчанию используется для rw запросов ReplicaInstanceType // Любой из описанных реплик ReplicaOrMasterInstanceType // Любая реплика если есть, если нет то любой мастер. По умолчанию используется при селекте )