activerecord

package
v1.12.1-b Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 18 Imported by: 8

Documentation

Index

Constants

View Source
const (
	PanicLoggerLevel uint32 = iota
	FatalLoggerLevel
	ErrorLoggerLevel
	WarnLoggerLevel
	InfoLoggerLevel
	DebugLoggerLevel
	TraceLoggerLevel
)
View Source
const (
	ContextLogprefix ctxKey = iota
)
View Source
const (
	ValueContextErrorField = "context"
)

Variables

View Source
var ErrNoData = errors.New("no data")

Functions

func InitActiveRecord

func InitActiveRecord(opts ...Option)

func ReinitActiveRecord

func ReinitActiveRecord(opts ...Option)

func WithShard

func WithShard(masters []OptionInterface, replicas []OptionInterface) clusterOption

Types

type ActiveRecord

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

func GetInstance

func GetInstance() *ActiveRecord

type Cluster

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

Тип описывающий кластер. Сейчас кластер - это набор шардов.

func AddClusterChecker added in v1.11.0

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 added in v1.11.0

func NewCluster(shardCnt int) *Cluster

func NewClusterInfo

func NewClusterInfo(opts ...clusterOption) *Cluster

Конструктор который позволяет проинициализировать новый кластер. В опциях передаются все шарды, сколько шардов, столько и опций. Используется в случаях, когда информация по кластеру прописана непосредственно в декларации модели, а не в конфиге. Так же используется при тестировании.

func (*Cluster) Append added in v1.11.0

func (c *Cluster) Append(shard Shard)

Append добавляет новый шард в кластер

func (*Cluster) Equal added in v1.11.1

func (c *Cluster) Equal(c2 *Cluster) bool

Equal сравнивает загруженные конфигурации кластеров на основе контрольной суммы всех инстансов кластера

func (*Cluster) NextMaster added in v1.11.0

func (c *Cluster) NextMaster(shardNum int) ShardInstance

NextMaster выбирает следующий доступный инстанс мастера в шарде shardNum

func (*Cluster) NextReplica added in v1.11.0

func (c *Cluster) NextReplica(shardNum int) (ShardInstance, bool)

NextMaster выбирает следующий доступный инстанс реплики в шарде shardNum

func (*Cluster) SetShardInstances added in v1.11.0

func (c *Cluster) SetShardInstances(shardNum int, instances []ShardInstance)

SetShardInstances заменяет инстансы кластера в шарде shardNum на инстансы из instances

func (*Cluster) ShardInstances added in v1.11.0

func (c *Cluster) ShardInstances(shardNum int) []ShardInstance

ShardInstances копия всех инстансов из шарды shardNum

func (*Cluster) Shards added in v1.11.0

func (c *Cluster) Shards() int

Shards кол-во доступных шард кластера

type ClusterCheckerInterface added in v1.11.0

type ClusterCheckerInterface interface {
	AddClusterChecker(ctx context.Context, path string, params ClusterConfigParameters) (*Cluster, error)
}

type ClusterConfigParameters added in v1.11.0

type ClusterConfigParameters struct {
	Globs         MapGlobParam
	OptionCreator func(ShardInstanceConfig) (OptionInterface, error)
	OptionChecker func(ctx context.Context, instance ShardInstance) (OptionInterface, error)
}

func (ClusterConfigParameters) Validate added in v1.11.0

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(ctx context.Context, confPath string, dfl ...bool) bool
	GetBoolIfExists(ctx context.Context, confPath string) (value bool, ok bool)
	GetInt(ctx context.Context, confPath string, dfl ...int) int
	GetIntIfExists(ctx context.Context, confPath string) (int, bool)
	GetDuration(ctx context.Context, confPath string, dfl ...time.Duration) time.Duration
	GetDurationIfExists(ctx context.Context, confPath string) (time.Duration, bool)
	GetString(ctx context.Context, confPath string, dfl ...string) string
	GetStringIfExists(ctx context.Context, confPath string) (string, bool)
	GetStrings(ctx context.Context, confPath string, dfl []string) []string
	GetStruct(ctx context.Context, confPath string, valuePtr interface{}) (bool, error)
	GetLastUpdateTime() time.Time
}

func Config

func Config() 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{}
}

type DefaultConfig

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

func NewDefaultConfig

func NewDefaultConfig() *DefaultConfig

func NewDefaultConfigFromMap

func NewDefaultConfigFromMap(cfg map[string]interface{}) *DefaultConfig

func (*DefaultConfig) GetBool

func (dc *DefaultConfig) GetBool(ctx context.Context, confPath string, dfl ...bool) bool

func (*DefaultConfig) GetBoolIfExists

func (dc *DefaultConfig) GetBoolIfExists(ctx context.Context, confPath string) (value bool, ok bool)

func (*DefaultConfig) GetDuration

func (dc *DefaultConfig) GetDuration(ctx context.Context, confPath string, dfl ...time.Duration) time.Duration

func (*DefaultConfig) GetDurationIfExists

func (dc *DefaultConfig) GetDurationIfExists(ctx context.Context, confPath string) (time.Duration, bool)

func (*DefaultConfig) GetInt

func (dc *DefaultConfig) GetInt(ctx context.Context, confPath string, dfl ...int) int

func (*DefaultConfig) GetIntIfExists

func (dc *DefaultConfig) GetIntIfExists(ctx context.Context, confPath string) (int, bool)

func (*DefaultConfig) GetLastUpdateTime

func (dc *DefaultConfig) GetLastUpdateTime() time.Time

func (*DefaultConfig) GetString

func (dc *DefaultConfig) GetString(ctx context.Context, confPath string, dfl ...string) string

func (*DefaultConfig) GetStringIfExists

func (dc *DefaultConfig) GetStringIfExists(ctx context.Context, confPath string) (string, bool)

func (*DefaultConfig) GetStrings

func (dc *DefaultConfig) GetStrings(ctx context.Context, confPath string, dfl []string) []string

func (*DefaultConfig) GetStruct

func (dc *DefaultConfig) GetStruct(ctx context.Context, confPath string, valuePtr interface{}) (bool, error)

type DefaultConfigCacher

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

Структура для кеширования полученных конфигураций. Инвалидация происходит посредством сравнения updateTime сданной труктуры и самого конфига. Используется для шаринга конфигов между можелями если они используют одну и ту же конфигурацию для подключений

func NewConfigCacher added in v1.11.0

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 DefaultLogger

type DefaultLogger struct {
	Fields ValueLogPrefix
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger() *DefaultLogger

func (*DefaultLogger) CollectQueries

func (l *DefaultLogger) CollectQueries(ctx context.Context, f func() (MockerLogger, error))

func (*DefaultLogger) Debug

func (l *DefaultLogger) Debug(ctx context.Context, args ...interface{})

func (*DefaultLogger) Error

func (l *DefaultLogger) Error(ctx context.Context, args ...interface{})

func (*DefaultLogger) Fatal

func (l *DefaultLogger) Fatal(ctx context.Context, args ...interface{})

func (*DefaultLogger) Info

func (l *DefaultLogger) Info(ctx context.Context, args ...interface{})

func (*DefaultLogger) Panic

func (l *DefaultLogger) Panic(ctx context.Context, args ...interface{})

func (*DefaultLogger) SetLogLevel

func (l *DefaultLogger) SetLogLevel(level uint32)

func (*DefaultLogger) SetLoggerValueToContext

func (l *DefaultLogger) SetLoggerValueToContext(ctx context.Context, val ValueLogPrefix) context.Context

func (*DefaultLogger) Trace

func (l *DefaultLogger) Trace(ctx context.Context, args ...interface{})

func (*DefaultLogger) Warn

func (l *DefaultLogger) Warn(ctx context.Context, args ...interface{})

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{}

func (*DefaultNoopMetricCount) Inc

func (*DefaultNoopMetricCount) Inc(ctx context.Context, name string, val float64)

type DefaultNoopMetricTimer

type DefaultNoopMetricTimer struct{}

func (*DefaultNoopMetricTimer) Finish

func (*DefaultNoopMetricTimer) Finish(ctx context.Context, name string)

func (*DefaultNoopMetricTimer) Timing

func (*DefaultNoopMetricTimer) Timing(ctx context.Context, name string)

type GroupHash added in v1.12.0

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

func NewGroupHash added in v1.12.0

func NewGroupHash(hash hash.Hash32) *GroupHash

func (*GroupHash) GetHash added in v1.12.0

func (o *GroupHash) GetHash() string

func (*GroupHash) UpdateHash added in v1.12.0

func (o *GroupHash) UpdateHash(data ...interface{}) error

type IprotoLogger

type IprotoLogger struct{}

func (IprotoLogger) Debugf

func (IprotoLogger) Debugf(ctx context.Context, fmtStr string, v ...interface{})

func (IprotoLogger) Printf

func (IprotoLogger) Printf(ctx context.Context, fmtStr string, v ...interface{})

type Limiter

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

func EmptyLimiter

func EmptyLimiter() Limiter

func NewLimitOffset

func NewLimitOffset(limit uint32, offset uint32) Limiter

func NewLimiter

func NewLimiter(limit uint32) Limiter

func NewThreshold

func NewThreshold(limit uint32) Limiter

func (Limiter) FullfillWarn

func (l Limiter) FullfillWarn() bool

func (Limiter) Limit

func (l Limiter) Limit() uint32

func (Limiter) Offset

func (l Limiter) Offset() uint32

func (Limiter) String

func (l Limiter) String() string

type LoggerInterface

type LoggerInterface interface {
	SetLoggerValueToContext(ctx context.Context, addVal ValueLogPrefix) context.Context

	SetLogLevel(level uint32)
	Fatal(ctx context.Context, args ...interface{})
	Error(ctx context.Context, args ...interface{})
	Warn(ctx context.Context, args ...interface{})
	Info(ctx context.Context, args ...interface{})
	Debug(ctx context.Context, args ...interface{})
	Trace(ctx context.Context, args ...interface{})

	CollectQueries(ctx context.Context, f func() (MockerLogger, error))
}

func Logger

func Logger() LoggerInterface

type MapGlobParam

type MapGlobParam struct {
	Timeout  time.Duration
	PoolSize int
}

Тип используемый для передачи набора значений по умолчанию для параметров

type MetricErrorCountInterface

type MetricErrorCountInterface interface {
	Inc(ctx context.Context, name string, val float64)
}

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 MetricStatCountInterface

type MetricStatCountInterface interface {
	Inc(ctx context.Context, name string, val float64)
}

type MetricTimerInterface

type MetricTimerInterface interface {
	Timing(ctx context.Context, name string)
	Finish(ctx context.Context, name string)
}

type MockConfig added in v1.11.0

type MockConfig struct {
	mock.Mock
}

MockConfig is an autogenerated mock type for the ConfigInterface type

func NewMockConfig added in v1.11.0

func NewMockConfig(t mockConstructorTestingTNewMockConfig) *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.

func (*MockConfig) EXPECT added in v1.11.0

func (_m *MockConfig) EXPECT() *MockConfig_Expecter

func (*MockConfig) GetBool added in v1.11.0

func (_m *MockConfig) GetBool(ctx context.Context, confPath string, dfl ...bool) bool

GetBool provides a mock function with given fields: ctx, confPath, dfl

func (*MockConfig) GetBoolIfExists added in v1.11.0

func (_m *MockConfig) GetBoolIfExists(ctx context.Context, confPath string) (bool, bool)

GetBoolIfExists provides a mock function with given fields: ctx, confPath

func (*MockConfig) GetDuration added in v1.11.0

func (_m *MockConfig) GetDuration(ctx context.Context, confPath string, dfl ...time.Duration) time.Duration

GetDuration provides a mock function with given fields: ctx, confPath, dfl

func (*MockConfig) GetDurationIfExists added in v1.11.0

func (_m *MockConfig) GetDurationIfExists(ctx context.Context, confPath string) (time.Duration, bool)

GetDurationIfExists provides a mock function with given fields: ctx, confPath

func (*MockConfig) GetInt added in v1.11.0

func (_m *MockConfig) GetInt(ctx context.Context, confPath string, dfl ...int) int

GetInt provides a mock function with given fields: ctx, confPath, dfl

func (*MockConfig) GetIntIfExists added in v1.11.0

func (_m *MockConfig) GetIntIfExists(ctx context.Context, confPath string) (int, bool)

GetIntIfExists provides a mock function with given fields: ctx, confPath

func (*MockConfig) GetLastUpdateTime added in v1.11.0

func (_m *MockConfig) GetLastUpdateTime() time.Time

GetLastUpdateTime provides a mock function with given fields:

func (*MockConfig) GetString added in v1.11.0

func (_m *MockConfig) GetString(ctx context.Context, confPath string, dfl ...string) string

GetString provides a mock function with given fields: ctx, confPath, dfl

func (*MockConfig) GetStringIfExists added in v1.11.0

func (_m *MockConfig) GetStringIfExists(ctx context.Context, confPath string) (string, bool)

GetStringIfExists provides a mock function with given fields: ctx, confPath

func (*MockConfig) GetStrings added in v1.11.0

func (_m *MockConfig) GetStrings(ctx context.Context, confPath string, dfl []string) []string

GetStrings provides a mock function with given fields: ctx, confPath, dfl

func (*MockConfig) GetStruct added in v1.11.0

func (_m *MockConfig) GetStruct(ctx context.Context, confPath string, valuePtr interface{}) (bool, error)

GetStruct provides a mock function with given fields: ctx, confPath, valuePtr

type MockConfig_Expecter added in v1.11.0

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

func (*MockConfig_Expecter) GetBool added in v1.11.0

func (_e *MockConfig_Expecter) GetBool(ctx interface{}, confPath interface{}, dfl ...interface{}) *MockConfig_GetBool_Call

GetBool is a helper method to define mock.On call

  • ctx context.Context
  • confPath string
  • dfl ...bool

func (*MockConfig_Expecter) GetBoolIfExists added in v1.11.0

func (_e *MockConfig_Expecter) GetBoolIfExists(ctx interface{}, confPath interface{}) *MockConfig_GetBoolIfExists_Call

GetBoolIfExists is a helper method to define mock.On call

  • ctx context.Context
  • confPath string

func (*MockConfig_Expecter) GetDuration added in v1.11.0

func (_e *MockConfig_Expecter) GetDuration(ctx interface{}, confPath interface{}, dfl ...interface{}) *MockConfig_GetDuration_Call

GetDuration is a helper method to define mock.On call

  • ctx context.Context
  • confPath string
  • dfl ...time.Duration

func (*MockConfig_Expecter) GetDurationIfExists added in v1.11.0

func (_e *MockConfig_Expecter) GetDurationIfExists(ctx interface{}, confPath interface{}) *MockConfig_GetDurationIfExists_Call

GetDurationIfExists is a helper method to define mock.On call

  • ctx context.Context
  • confPath string

func (*MockConfig_Expecter) GetInt added in v1.11.0

func (_e *MockConfig_Expecter) GetInt(ctx interface{}, confPath interface{}, dfl ...interface{}) *MockConfig_GetInt_Call

GetInt is a helper method to define mock.On call

  • ctx context.Context
  • confPath string
  • dfl ...int

func (*MockConfig_Expecter) GetIntIfExists added in v1.11.0

func (_e *MockConfig_Expecter) GetIntIfExists(ctx interface{}, confPath interface{}) *MockConfig_GetIntIfExists_Call

GetIntIfExists is a helper method to define mock.On call

  • ctx context.Context
  • confPath string

func (*MockConfig_Expecter) GetLastUpdateTime added in v1.11.0

func (_e *MockConfig_Expecter) GetLastUpdateTime() *MockConfig_GetLastUpdateTime_Call

GetLastUpdateTime is a helper method to define mock.On call

func (*MockConfig_Expecter) GetString added in v1.11.0

func (_e *MockConfig_Expecter) GetString(ctx interface{}, confPath interface{}, dfl ...interface{}) *MockConfig_GetString_Call

GetString is a helper method to define mock.On call

  • ctx context.Context
  • confPath string
  • dfl ...string

func (*MockConfig_Expecter) GetStringIfExists added in v1.11.0

func (_e *MockConfig_Expecter) GetStringIfExists(ctx interface{}, confPath interface{}) *MockConfig_GetStringIfExists_Call

GetStringIfExists is a helper method to define mock.On call

  • ctx context.Context
  • confPath string

func (*MockConfig_Expecter) GetStrings added in v1.11.0

func (_e *MockConfig_Expecter) GetStrings(ctx interface{}, confPath interface{}, dfl interface{}) *MockConfig_GetStrings_Call

GetStrings is a helper method to define mock.On call

  • ctx context.Context
  • confPath string
  • dfl []string

func (*MockConfig_Expecter) GetStruct added in v1.11.0

func (_e *MockConfig_Expecter) GetStruct(ctx interface{}, confPath interface{}, valuePtr interface{}) *MockConfig_GetStruct_Call

GetStruct is a helper method to define mock.On call

  • ctx context.Context
  • confPath string
  • valuePtr interface{}

type MockConfig_GetBoolIfExists_Call added in v1.11.0

type MockConfig_GetBoolIfExists_Call struct {
	*mock.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 added in v1.11.0

func (*MockConfig_GetBoolIfExists_Call) Run added in v1.11.0

func (*MockConfig_GetBoolIfExists_Call) RunAndReturn added in v1.11.0

type MockConfig_GetBool_Call added in v1.11.0

type MockConfig_GetBool_Call struct {
	*mock.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 added in v1.11.0

func (*MockConfig_GetBool_Call) Run added in v1.11.0

func (_c *MockConfig_GetBool_Call) Run(run func(ctx context.Context, confPath string, dfl ...bool)) *MockConfig_GetBool_Call

func (*MockConfig_GetBool_Call) RunAndReturn added in v1.11.0

type MockConfig_GetDurationIfExists_Call added in v1.11.0

type MockConfig_GetDurationIfExists_Call struct {
	*mock.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 added in v1.11.0

func (*MockConfig_GetDurationIfExists_Call) Run added in v1.11.0

func (*MockConfig_GetDurationIfExists_Call) RunAndReturn added in v1.11.0

type MockConfig_GetDuration_Call added in v1.11.0

type MockConfig_GetDuration_Call struct {
	*mock.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 added in v1.11.0

func (*MockConfig_GetDuration_Call) Run added in v1.11.0

func (*MockConfig_GetDuration_Call) RunAndReturn added in v1.11.0

type MockConfig_GetIntIfExists_Call added in v1.11.0

type MockConfig_GetIntIfExists_Call struct {
	*mock.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 added in v1.11.0

func (*MockConfig_GetIntIfExists_Call) Run added in v1.11.0

func (*MockConfig_GetIntIfExists_Call) RunAndReturn added in v1.11.0

type MockConfig_GetInt_Call added in v1.11.0

type MockConfig_GetInt_Call struct {
	*mock.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 added in v1.11.0

func (*MockConfig_GetInt_Call) Run added in v1.11.0

func (_c *MockConfig_GetInt_Call) Run(run func(ctx context.Context, confPath string, dfl ...int)) *MockConfig_GetInt_Call

func (*MockConfig_GetInt_Call) RunAndReturn added in v1.11.0

func (_c *MockConfig_GetInt_Call) RunAndReturn(run func(context.Context, string, ...int) int) *MockConfig_GetInt_Call

type MockConfig_GetLastUpdateTime_Call added in v1.11.0

type MockConfig_GetLastUpdateTime_Call struct {
	*mock.Call
}

MockConfig_GetLastUpdateTime_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLastUpdateTime'

func (*MockConfig_GetLastUpdateTime_Call) Return added in v1.11.0

func (*MockConfig_GetLastUpdateTime_Call) Run added in v1.11.0

func (*MockConfig_GetLastUpdateTime_Call) RunAndReturn added in v1.11.0

type MockConfig_GetStringIfExists_Call added in v1.11.0

type MockConfig_GetStringIfExists_Call struct {
	*mock.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 added in v1.11.0

func (*MockConfig_GetStringIfExists_Call) Run added in v1.11.0

func (*MockConfig_GetStringIfExists_Call) RunAndReturn added in v1.11.0

type MockConfig_GetString_Call added in v1.11.0

type MockConfig_GetString_Call struct {
	*mock.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 added in v1.11.0

func (*MockConfig_GetString_Call) Run added in v1.11.0

func (_c *MockConfig_GetString_Call) Run(run func(ctx context.Context, confPath string, dfl ...string)) *MockConfig_GetString_Call

func (*MockConfig_GetString_Call) RunAndReturn added in v1.11.0

type MockConfig_GetStrings_Call added in v1.11.0

type MockConfig_GetStrings_Call struct {
	*mock.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 added in v1.11.0

func (*MockConfig_GetStrings_Call) Run added in v1.11.0

func (_c *MockConfig_GetStrings_Call) Run(run func(ctx context.Context, confPath string, dfl []string)) *MockConfig_GetStrings_Call

func (*MockConfig_GetStrings_Call) RunAndReturn added in v1.11.0

type MockConfig_GetStruct_Call added in v1.11.0

type MockConfig_GetStruct_Call struct {
	*mock.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 added in v1.11.0

func (*MockConfig_GetStruct_Call) Run added in v1.11.0

func (_c *MockConfig_GetStruct_Call) Run(run func(ctx context.Context, confPath string, valuePtr interface{})) *MockConfig_GetStruct_Call

func (*MockConfig_GetStruct_Call) RunAndReturn added in v1.11.0

func (_c *MockConfig_GetStruct_Call) RunAndReturn(run func(context.Context, string, interface{}) (bool, error)) *MockConfig_GetStruct_Call

type MockerLogger

type MockerLogger struct {
	// Название моккера
	MockerName string

	// Вызовы моккера для создания списка моков
	Mockers string

	// Получение списка фикстур для моков
	FixturesSelector string

	// Название пакета для которого необходимо добавить моки
	ResultName string

	// Результат возвращаемый селектором
	Results any
}

Структура используемая для сбора статистики по запросам

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithConfig

func WithConfig(config ConfigInterface) Option

func WithConfigCacher added in v1.11.0

func WithConfigCacher(configCacher ConfigCacherInterface) Option

func WithConnectionPinger added in v1.11.0

func WithConnectionPinger(pc ClusterCheckerInterface) Option

func WithLogger

func WithLogger(logger LoggerInterface) Option

func WithMetrics

func WithMetrics(metric MetricInterface) Option

type OptionInterface

type OptionInterface interface {
	GetConnectionID() string
	InstanceMode() ServerModeType
}

Интерфейс которому должен соответствовать билдер опций подключения к конретному инстансу

type SelectorLimiter

type SelectorLimiter interface {
	Limit() uint32
	Offset() uint32
	FullfillWarn() bool
	fmt.Stringer
}

type SerializerInterface

type SerializerInterface interface {
	Unmarshal(val interface{}) (interface{}, error)
	Marshal(data interface{}) (interface{}, error)
}

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 added in v1.11.0

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 int
	Addr     string
	User     string
	Password string
}

Структура используется для описания конфигурации конктретного инстанса

type ShardInstanceType

type ShardInstanceType uint8

Тип и константы для выбора инстанса в шарде

const (
	MasterInstanceType          ShardInstanceType = iota // Любой из описанных мастеров. По умолчанию используется для rw запросов
	ReplicaInstanceType                                  // Любой из описанных реплик
	ReplicaOrMasterInstanceType                          // Любая реплика если есть, если нет то любой мастер. По умолчанию используется при селекте
)

type ValueLogPrefix

type ValueLogPrefix map[string]interface{}

Jump to

Keyboard shortcuts

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