octopus

package
v1.9.4 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: MIT Imports: 20 Imported by: 9

Documentation

Index

Constants

View Source
const (
	DefaultTimeout           = 20 * time.Millisecond
	DefaultConnectionTimeout = 20 * time.Millisecond
	DefaultRedialInterval    = 50 * time.Millisecond
	DefaultPingInterval      = 1 * time.Second
	DefaultPoolSize          = 1
)

Константы определяющие дефолтное поведение конектора к octopus-у

View Source
const (
	SpaceLen uint32 = 4
	IndexLen
	LimitLen
	OffsetLen
	FlagsLen
	FieldNumLen
	OpsLen
	OpFieldNumLen
	OpOpLen = 1
)
View Source
const (
	RcOK                   = RetCode(0x0)
	RcReadOnly             = RetCode(0x0401)
	RcLocked               = RetCode(0x0601)
	RcMemoryIssue          = RetCode(0x0701)
	RcNonMaster            = RetCode(0x0102)
	RcIllegalParams        = RetCode(0x0202)
	RcSecondaryPort        = RetCode(0x0301)
	RcBadIntegrity         = RetCode(0x0801)
	RcUnsupportedCommand   = RetCode(0x0a02)
	RcDuplicate            = RetCode(0x2002)
	RcWrongField           = RetCode(0x1e02)
	RcWrongNumber          = RetCode(0x1f02)
	RcWrongVersion         = RetCode(0x2602)
	RcWalIO                = RetCode(0x2702)
	RcDoesntExists         = RetCode(0x3102)
	RcStoredProcNotDefined = RetCode(0x3202)
	RcLuaError             = RetCode(0x3302)
	RcTupleExists          = RetCode(0x3702)
	RcDuplicateKey         = RetCode(0x3802)
)

Variables

View Source
var DataFormat = []Format{String}
View Source
var (
	ErrConnection = fmt.Errorf("error dial to box")
)
View Source
var FloatFormat = []Format{Float32, Float64}
View Source
var UnsignedFormat = []Format{Uint8, Uint16, Uint32, Uint64, Uint}

Functions

func BoolToUint

func BoolToUint(v bool) uint8

func ByteLen

func ByteLen(length uint32) uint32

func GetInsertModeName

func GetInsertModeName(mode InsertMode) string

func GetOpCodeName

func GetOpCodeName(op OpCode) string

func PackBool

func PackBool(w []byte, v bool, mode iproto.PackMode) ([]byte, error)

func PackDelete

func PackDelete(ns uint32, primaryKey [][]byte) []byte

func PackDeleteFlagsVal

func PackDeleteFlagsVal(w []byte, ret bool) []byte

func PackField

func PackField(w []byte, field []byte) []byte

func PackFieldNums

func PackFieldNums(w []byte, cnt uint32) []byte

func PackIndexNum

func PackIndexNum(w []byte, indexnum uint32) []byte

func PackInsertReplace

func PackInsertReplace(ns uint32, insertMode InsertMode, tuple [][]byte) []byte

func PackKey

func PackKey(w []byte, key [][]byte) []byte

func PackLimit

func PackLimit(w []byte, limit uint32) []byte

func PackLua

func PackLua(name string, args ...string) []byte

func PackMockResponse

func PackMockResponse(ome []MockEntities) ([]byte, error)

func PackOffset

func PackOffset(w []byte, offset uint32) []byte

func PackRequestFlagsVal

func PackRequestFlagsVal(w []byte, ret bool, mode InsertMode) []byte

func PackResopnseStatus

func PackResopnseStatus(statusCode RetCode, data [][][]byte) ([]byte, error)

func PackSelect

func PackSelect(ns, indexnum, offset, limit uint32, keys [][][]byte) []byte

func PackSpace

func PackSpace(w []byte, space uint32) []byte

func PackString

func PackString(w []byte, field string, mode iproto.PackMode) []byte

func PackTuple

func PackTuple(w []byte, keys [][]byte) []byte

func PackTuples

func PackTuples(w []byte, keys [][][]byte) []byte

func PackUpdate

func PackUpdate(ns uint32, primaryKey [][]byte, updateOps []Ops) []byte

func PackedFieldLen

func PackedFieldLen(field []byte) uint32

func PackedKeyLen

func PackedKeyLen(keys [][]byte) (length uint32)

func PackedKeysLen

func PackedKeysLen(keys [][]byte) (length uint32)

func PackedTupleLen

func PackedTupleLen(keys [][]byte) (length uint32)

func PackedTuplesLen

func PackedTuplesLen(keys [][][]byte) (length uint32)

func PackedUpdateOpsLen

func PackedUpdateOpsLen(updateOps []Ops) (length uint32)

func UintToBool

func UintToBool(v uint8) bool

func UnpackDelete

func UnpackDelete(data []byte) (ns uint32, primaryKey [][]byte, err error)

func UnpackField

func UnpackField(r *bytes.Reader) ([]byte, error)

func UnpackFieldNums

func UnpackFieldNums(r *bytes.Reader) (uint32, error)

func UnpackIndexNum

func UnpackIndexNum(r *bytes.Reader) (uint32, error)

func UnpackKey

func UnpackKey(r *bytes.Reader) ([][]byte, error)

func UnpackLimit

func UnpackLimit(r *bytes.Reader) (uint32, error)

func UnpackLua added in v1.7.0

func UnpackLua(data []byte) (name string, args [][]byte, err error)

func UnpackOffset

func UnpackOffset(r *bytes.Reader) (uint32, error)

func UnpackResopnseStatus

func UnpackResopnseStatus(data []byte) (uint32, []byte, error)

func UnpackSelect

func UnpackSelect(data []byte) (ns, indexnum, offset, limit uint32, keys [][][]byte, err error)

func UnpackSpace

func UnpackSpace(r *bytes.Reader) (uint32, error)

func UnpackString

func UnpackString(r *bytes.Reader, res *string, mode iproto.PackMode) error

func UnpackTuple

func UnpackTuple(r *bytes.Reader) ([][]byte, error)

func UnpackTuples

func UnpackTuples(r *bytes.Reader) ([][][]byte, error)

func WrapTriggerWithOnUsePromise

func WrapTriggerWithOnUsePromise(trigger func(types []FixtureType) []FixtureType) (wrappedTrigger func(types []FixtureType) []FixtureType, isUsed func() bool)

Types

type BaseField

type BaseField struct {
	Collection      []ModelStruct
	UpdateOps       []Ops
	ExtraFields     [][]byte
	Objects         map[string][]ModelStruct
	FieldsetAltered bool
	Exists          bool
	ShardNum        uint32
	IsReplica       bool
	Readonly        bool
	Repaired        bool
}

type BoxMode

type BoxMode uint8
const (
	ReplicaMaster BoxMode = iota
	MasterReplica
	ReplicaOnly
	MasterOnly
	SelectModeDefault = ReplicaMaster
)

type CallMockFixture added in v1.7.0

type CallMockFixture struct {
	ProcName   string
	Args       [][]byte
	RespTuples []TupleData
}

type CheckUsesFixtureType

type CheckUsesFixtureType uint8
const (
	AnyUsesFixtures CheckUsesFixtureType = iota
	AllFixtureUses
	AllFixtureUsesOnlyOnce
)

Константы для проверки использования фикстур

type Connection

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

func Box added in v1.6.0

Box - возвращает коннектор для БД TODO - сделать статистику по используемым инстансам - прикрутить локальный пингер и исключать недоступные инстансы

func GetConnection

func GetConnection(ctx context.Context, octopusOpts *ConnectionOptions) (*Connection, error)

func (*Connection) Call

func (c *Connection) Call(ctx context.Context, rt RequetsTypeType, data []byte) ([]byte, error)

func (*Connection) Close

func (c *Connection) Close()

func (*Connection) Done

func (c *Connection) Done() <-chan struct{}

func (*Connection) Info

func (c *Connection) Info() string

func (*Connection) InstanceMode

func (c *Connection) InstanceMode() any

type ConnectionOption

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

ConnectionOption - интерфейс которому должны соответствовать опции передаваемые в конструктор

func WithIntervals

func WithIntervals(redial, maxRedial, ping time.Duration) ConnectionOption

WithIntervals - опция для изменения интервалов

func WithPoolLogger added in v1.7.0

func WithPoolLogger(logger iproto.Logger) ConnectionOption

WithPoolLogger - опция для логера конекшен пула

func WithPoolSize

func WithPoolSize(size int) ConnectionOption

WithPoolSize - опция для изменения размера пулла подключений

func WithTimeout

func WithTimeout(request, connection time.Duration) ConnectionOption

WithTimeout - опция для изменений таймаутов

type ConnectionOptions

type ConnectionOptions struct {
	Mode ServerModeType
	// contains filtered or unexported fields
}

ConnectionOptions - опции используемые для подключения

func NewOptions

func NewOptions(server string, mode ServerModeType, opts ...ConnectionOption) (*ConnectionOptions, error)

NewOptions - cоздание структуры с опциями и дефолтными значениями. Для мидификации значений по умолчанию, надо передавать опции в конструктор

func (*ConnectionOptions) GetConnectionID

func (o *ConnectionOptions) GetConnectionID() string

GetConnectionID - получение ConnecitionID. После первого получения, больше нельзя его модифицировать. Можно только новый Options создать

func (*ConnectionOptions) InstanceMode

func (o *ConnectionOptions) InstanceMode() any

InstanceMode - метод для получения режима аботы инстанса RO или RW

func (*ConnectionOptions) UpdateHash

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

UpdateHash - функция расчета ConnectionID, необходима для шаринга конектов между моделями.

type CountFlags

type CountFlags uint32
const (
	UniqRespFlag CountFlags = 1 << iota
	NeedRespFlag
)

type DefaultLogger

type DefaultLogger struct {
	DebugMeta RepositoryDebugMeta
}

func (*DefaultLogger) Debug

func (l *DefaultLogger) Debug(fmt string, args ...any)

func (*DefaultLogger) DebugCallRequest added in v1.7.0

func (l *DefaultLogger) DebugCallRequest(procName string, args [][]byte, fixtures ...CallMockFixture)

func (*DefaultLogger) DebugDeleteRequest

func (l *DefaultLogger) DebugDeleteRequest(ns uint32, primaryKey [][]byte, fixture ...DeleteMockFixture)

func (*DefaultLogger) DebugInsertRequest

func (l *DefaultLogger) DebugInsertRequest(ns uint32, needRetVal bool, insertMode InsertMode, tuple TupleData, fixture ...InsertMockFixture)

func (*DefaultLogger) DebugSelectRequest

func (l *DefaultLogger) DebugSelectRequest(ns uint32, indexnum uint32, offset uint32, limit uint32, keys [][][]byte, fixture ...SelectMockFixture)

func (*DefaultLogger) DebugUpdateRequest

func (l *DefaultLogger) DebugUpdateRequest(ns uint32, primaryKey [][]byte, updateOps []Ops, fixture ...UpdateMockFixture)

type DeleteMockFixture added in v1.7.0

type DeleteMockFixture struct {
	PrimaryKey [][]byte
}

type FixtureType

type FixtureType struct {
	// Уникальный идентификатор фикстуры
	ID uint32

	// Msg - задаёт тип запроса (select, insert, delete, update)
	Msg RequetsTypeType

	// Байтовое представление запроса
	Request []byte

	// Байтовое представление ответа
	Response []byte

	// Возвращаемые объекты. Используется в режиме mock
	RespObjs []MockEntities

	// Trigger - функция, которая будет выполнена при обработке запроса
	// в случае если надо проверить insert или delete внутри этой функции
	// можно модифицировать список фикстур сервера
	Trigger func([]FixtureType) []FixtureType
}

FixtureType - структура определяющая ответ Response для конкретного запроса Request

func CreateCallFixture added in v1.6.0

func CreateCallFixture(reqData func(mocks []MockEntities) []byte, respEnt []MockEntities) (FixtureType, error)

CreateCallFixture - конструктор фикстур для вызова процедуры

func CreateDeleteFixture added in v1.8.1

func CreateDeleteFixture(reqData []byte, trigger func([]FixtureType) []FixtureType) FixtureType

func CreateFixture

func CreateFixture(id uint32, msg uint8, reqData []byte, respData []byte, trigger func([]FixtureType) []FixtureType) FixtureType

CreateFixture - конструктор фикстур

func CreateInsertOrReplaceFixture

func CreateInsertOrReplaceFixture(entity MockEntities, reqData []byte, trigger func([]FixtureType) []FixtureType) FixtureType

func CreateSelectFixture

func CreateSelectFixture(reqData func(mocks []MockEntities) []byte, respEnt []MockEntities) (FixtureType, error)

CreateSelectFixture - конструктор фикстур для select-а

func CreateUpdateFixture

func CreateUpdateFixture(reqData []byte, trigger func([]FixtureType) []FixtureType) FixtureType

type Format

type Format string
const (
	Uint8       Format = "uint8"
	Uint16      Format = "uint16"
	Uint32      Format = "uint32"
	Uint64      Format = "uint64"
	Uint        Format = "uint"
	Int8        Format = "int8"
	Int16       Format = "int16"
	Int32       Format = "int32"
	Int64       Format = "int64"
	Int         Format = "int"
	String      Format = "string"
	Bool        Format = "bool"
	Float32     Format = "float32"
	Float64     Format = "float64"
	StringArray Format = "[]string"
	ByteArray   Format = "[]byte"
)

type InsertMockFixture added in v1.7.0

type InsertMockFixture struct {
	NeedRetVal bool
	InsertMode InsertMode
	Tuple      TupleData
}

type InsertMode

type InsertMode uint8
const (
	InsertModeInserOrReplace InsertMode = iota
	InsertModeInsert
	InsertModeReplace
)

func UnpackInsertReplace

func UnpackInsertReplace(data []byte) (ns uint32, needRetVal bool, insertMode InsertMode, tuple [][]byte, err error)

func UnpackRequestFlagsVal

func UnpackRequestFlagsVal(r *bytes.Reader) (bool, InsertMode, error)

type MockEntities

type MockEntities interface {
	// Метод который позволяет отдать ответ из mock сервера
	MockSelectResponse() ([][]byte, error)

	// Метод который позволяет поднять сущность из БД
	RepoSelector(ctx context.Context) (any, error)
}

type MockMockServerLogger added in v1.7.0

type MockMockServerLogger struct {
	mock.Mock
}

MockMockServerLogger is an autogenerated mock type for the MockServerLogger type

func NewMockMockServerLogger added in v1.7.0

func NewMockMockServerLogger(t mockConstructorTestingTNewMockMockServerLogger) *MockMockServerLogger

NewMockMockServerLogger creates a new instance of MockMockServerLogger. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockMockServerLogger) Debug added in v1.7.0

func (_m *MockMockServerLogger) Debug(fmt string, args ...interface{})

Debug provides a mock function with given fields: fmt, args

func (*MockMockServerLogger) DebugCallRequest added in v1.7.0

func (_m *MockMockServerLogger) DebugCallRequest(procName string, args [][]byte, fixtures ...CallMockFixture)

DebugCallRequest provides a mock function with given fields: procName, args, fixtures

func (*MockMockServerLogger) DebugDeleteRequest added in v1.7.0

func (_m *MockMockServerLogger) DebugDeleteRequest(ns uint32, primaryKey [][]byte, fixtures ...DeleteMockFixture)

DebugDeleteRequest provides a mock function with given fields: ns, primaryKey, fixtures

func (*MockMockServerLogger) DebugInsertRequest added in v1.7.0

func (_m *MockMockServerLogger) DebugInsertRequest(ns uint32, needRetVal bool, insertMode InsertMode, tuple TupleData, fixtures ...InsertMockFixture)

DebugInsertRequest provides a mock function with given fields: ns, needRetVal, insertMode, tuple, fixtures

func (*MockMockServerLogger) DebugSelectRequest added in v1.7.0

func (_m *MockMockServerLogger) DebugSelectRequest(ns uint32, indexnum uint32, offset uint32, limit uint32, keys [][][]byte, fixtures ...SelectMockFixture)

DebugSelectRequest provides a mock function with given fields: ns, indexnum, offset, limit, keys, fixtures

func (*MockMockServerLogger) DebugUpdateRequest added in v1.7.0

func (_m *MockMockServerLogger) DebugUpdateRequest(ns uint32, primaryKey [][]byte, updateOps []Ops, fixtures ...UpdateMockFixture)

DebugUpdateRequest provides a mock function with given fields: ns, primaryKey, updateOps, fixtures

func (*MockMockServerLogger) EXPECT added in v1.7.0

type MockMockServerLogger_DebugCallRequest_Call added in v1.7.0

type MockMockServerLogger_DebugCallRequest_Call struct {
	*mock.Call
}

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

func (*MockMockServerLogger_DebugCallRequest_Call) Return added in v1.7.0

func (*MockMockServerLogger_DebugCallRequest_Call) Run added in v1.7.0

func (*MockMockServerLogger_DebugCallRequest_Call) RunAndReturn added in v1.7.0

type MockMockServerLogger_DebugDeleteRequest_Call added in v1.7.0

type MockMockServerLogger_DebugDeleteRequest_Call struct {
	*mock.Call
}

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

func (*MockMockServerLogger_DebugDeleteRequest_Call) Return added in v1.7.0

func (*MockMockServerLogger_DebugDeleteRequest_Call) Run added in v1.7.0

func (*MockMockServerLogger_DebugDeleteRequest_Call) RunAndReturn added in v1.7.0

type MockMockServerLogger_DebugInsertRequest_Call added in v1.7.0

type MockMockServerLogger_DebugInsertRequest_Call struct {
	*mock.Call
}

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

func (*MockMockServerLogger_DebugInsertRequest_Call) Return added in v1.7.0

func (*MockMockServerLogger_DebugInsertRequest_Call) Run added in v1.7.0

func (*MockMockServerLogger_DebugInsertRequest_Call) RunAndReturn added in v1.7.0

type MockMockServerLogger_DebugSelectRequest_Call added in v1.7.0

type MockMockServerLogger_DebugSelectRequest_Call struct {
	*mock.Call
}

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

func (*MockMockServerLogger_DebugSelectRequest_Call) Return added in v1.7.0

func (*MockMockServerLogger_DebugSelectRequest_Call) Run added in v1.7.0

func (_c *MockMockServerLogger_DebugSelectRequest_Call) Run(run func(ns uint32, indexnum uint32, offset uint32, limit uint32, keys [][][]byte, fixtures ...SelectMockFixture)) *MockMockServerLogger_DebugSelectRequest_Call

func (*MockMockServerLogger_DebugSelectRequest_Call) RunAndReturn added in v1.7.0

type MockMockServerLogger_DebugUpdateRequest_Call added in v1.7.0

type MockMockServerLogger_DebugUpdateRequest_Call struct {
	*mock.Call
}

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

func (*MockMockServerLogger_DebugUpdateRequest_Call) Return added in v1.7.0

func (*MockMockServerLogger_DebugUpdateRequest_Call) Run added in v1.7.0

func (_c *MockMockServerLogger_DebugUpdateRequest_Call) Run(run func(ns uint32, primaryKey [][]byte, updateOps []Ops, fixtures ...UpdateMockFixture)) *MockMockServerLogger_DebugUpdateRequest_Call

func (*MockMockServerLogger_DebugUpdateRequest_Call) RunAndReturn added in v1.7.0

type MockMockServerLogger_Debug_Call added in v1.7.0

type MockMockServerLogger_Debug_Call struct {
	*mock.Call
}

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

func (*MockMockServerLogger_Debug_Call) Return added in v1.7.0

func (*MockMockServerLogger_Debug_Call) Run added in v1.7.0

func (_c *MockMockServerLogger_Debug_Call) Run(run func(fmt string, args ...interface{})) *MockMockServerLogger_Debug_Call

func (*MockMockServerLogger_Debug_Call) RunAndReturn added in v1.7.0

func (_c *MockMockServerLogger_Debug_Call) RunAndReturn(run func(string, ...interface{})) *MockMockServerLogger_Debug_Call

type MockMockServerLogger_Expecter added in v1.7.0

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

func (*MockMockServerLogger_Expecter) Debug added in v1.7.0

func (_e *MockMockServerLogger_Expecter) Debug(fmt interface{}, args ...interface{}) *MockMockServerLogger_Debug_Call

Debug is a helper method to define mock.On call

  • fmt string
  • args ...interface{}

func (*MockMockServerLogger_Expecter) DebugCallRequest added in v1.7.0

func (_e *MockMockServerLogger_Expecter) DebugCallRequest(procName interface{}, args interface{}, fixtures ...interface{}) *MockMockServerLogger_DebugCallRequest_Call

DebugCallRequest is a helper method to define mock.On call

  • procName string
  • args [][]byte
  • fixtures ...CallMockFixture

func (*MockMockServerLogger_Expecter) DebugDeleteRequest added in v1.7.0

func (_e *MockMockServerLogger_Expecter) DebugDeleteRequest(ns interface{}, primaryKey interface{}, fixtures ...interface{}) *MockMockServerLogger_DebugDeleteRequest_Call

DebugDeleteRequest is a helper method to define mock.On call

  • ns uint32
  • primaryKey [][]byte
  • fixtures ...DeleteMockFixture

func (*MockMockServerLogger_Expecter) DebugInsertRequest added in v1.7.0

func (_e *MockMockServerLogger_Expecter) DebugInsertRequest(ns interface{}, needRetVal interface{}, insertMode interface{}, tuple interface{}, fixtures ...interface{}) *MockMockServerLogger_DebugInsertRequest_Call

DebugInsertRequest is a helper method to define mock.On call

  • ns uint32
  • needRetVal bool
  • insertMode InsertMode
  • tuple TupleData
  • fixtures ...InsertMockFixture

func (*MockMockServerLogger_Expecter) DebugSelectRequest added in v1.7.0

func (_e *MockMockServerLogger_Expecter) DebugSelectRequest(ns interface{}, indexnum interface{}, offset interface{}, limit interface{}, keys interface{}, fixtures ...interface{}) *MockMockServerLogger_DebugSelectRequest_Call

DebugSelectRequest is a helper method to define mock.On call

  • ns uint32
  • indexnum uint32
  • offset uint32
  • limit uint32
  • keys [][][]byte
  • fixtures ...SelectMockFixture

func (*MockMockServerLogger_Expecter) DebugUpdateRequest added in v1.7.0

func (_e *MockMockServerLogger_Expecter) DebugUpdateRequest(ns interface{}, primaryKey interface{}, updateOps interface{}, fixtures ...interface{}) *MockMockServerLogger_DebugUpdateRequest_Call

DebugUpdateRequest is a helper method to define mock.On call

  • ns uint32
  • primaryKey [][]byte
  • updateOps []Ops
  • fixtures ...UpdateMockFixture

type MockServer

type MockServer struct {

	// Мьютекс для работы с триггерами
	sync.Mutex
	// contains filtered or unexported fields
}

func InitMockServer

func InitMockServer(opts ...MockServerOption) (*MockServer, error)

func (*MockServer) DebugFixtureNotFound

func (oms *MockServer) DebugFixtureNotFound(msg uint8, req []byte)

DebugFixtureNotFound Prepares data for detailed content logging in human readable format and call the MockServerLogger function on a specific RequestType

func (*MockServer) GetServerHostPort

func (oms *MockServer) GetServerHostPort() string

func (*MockServer) Handler

func (oms *MockServer) Handler(ctx context.Context, c iproto.Conn, p iproto.Packet)

func (*MockServer) ProcessRequest

func (oms *MockServer) ProcessRequest(msg uint8, req []byte) ([]byte, bool)

func (*MockServer) SetFixtures

func (oms *MockServer) SetFixtures(oft []FixtureType)

func (*MockServer) Start

func (oms *MockServer) Start() error

func (*MockServer) Stop

func (oms *MockServer) Stop() error

type MockServerLogger

type MockServerLogger interface {
	Debug(fmt string, args ...any)
	DebugSelectRequest(ns uint32, indexnum uint32, offset uint32, limit uint32, keys [][][]byte, fixtures ...SelectMockFixture)
	DebugUpdateRequest(ns uint32, primaryKey [][]byte, updateOps []Ops, fixtures ...UpdateMockFixture)
	DebugInsertRequest(ns uint32, needRetVal bool, insertMode InsertMode, tuple TupleData, fixtures ...InsertMockFixture)
	DebugDeleteRequest(ns uint32, primaryKey [][]byte, fixtures ...DeleteMockFixture)
	DebugCallRequest(procName string, args [][]byte, fixtures ...CallMockFixture)
}

type MockServerOption

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

func WithHost

func WithHost(host, port string) MockServerOption

WithHost - опция для изменения сервера в конфиге

func WithIprotoLogger added in v1.7.0

func WithIprotoLogger(logger iproto.Logger) MockServerOption

func WithLogger

func WithLogger(logger MockServerLogger) MockServerOption

type ModelStruct

type ModelStruct interface {
	Insert(ctx context.Context) error
	Replace(ctx context.Context) error
	InsertOrReplace(ctx context.Context) error
	Update(ctx context.Context) error
	Delete(ctx context.Context) error
}

type MutatorField added in v1.9.0

type MutatorField struct {
	OpFunc        map[OpCode]string
	PartialFields map[string]any
	UpdateOps     []Ops
}

type NopIprotoLogger added in v1.7.0

type NopIprotoLogger struct{}

func (NopIprotoLogger) Debugf added in v1.7.0

func (l NopIprotoLogger) Debugf(ctx context.Context, fmt string, v ...interface{})

func (NopIprotoLogger) Printf added in v1.7.0

func (l NopIprotoLogger) Printf(ctx context.Context, fmt string, v ...interface{})

type OpCode

type OpCode uint8
const (
	OpSet OpCode = iota
	OpAdd
	OpAnd
	OpXor
	OpOr
	OpSplice
	OpDelete
	OpInsert
	OpUpdate
)

type Ops

type Ops struct {
	Field uint32
	Op    OpCode
	Value []byte
}

func UnpackUpdate

func UnpackUpdate(data []byte) (ns uint32, primaryKey [][]byte, updateOps []Ops, err error)

type RepositoryDebugMeta

type RepositoryDebugMeta interface {
	GetSelectDebugInfo(ns uint32, indexnum uint32, offset uint32, limit uint32, keys [][][]byte, fixture ...SelectMockFixture) string
	GetUpdateDebugInfo(ns uint32, primaryKey [][]byte, updateOps []Ops, fixture ...UpdateMockFixture) string
	GetInsertDebugInfo(ns uint32, needRetVal bool, insertMode InsertMode, tuple TupleData, fixture ...InsertMockFixture) string
	GetDeleteDebugInfo(ns uint32, primaryKey [][]byte, fixture ...DeleteMockFixture) string
	GetCallDebugInfo(procName string, args [][]byte, fixture ...CallMockFixture) string
}

type RequetsTypeType

type RequetsTypeType uint8
const (
	RequestTypeInsert RequetsTypeType = 13
	RequestTypeSelect RequetsTypeType = 17
	RequestTypeUpdate RequetsTypeType = 19
	RequestTypeDelete RequetsTypeType = 21
	RequestTypeCall   RequetsTypeType = 22
)

func (RequetsTypeType) String added in v1.7.0

func (r RequetsTypeType) String() string

type RetCode

type RetCode uint32

type SelectMockFixture added in v1.7.0

type SelectMockFixture struct {
	Indexnum   uint32
	Offset     uint32
	Limit      uint32
	Keys       [][][]byte
	RespTuples []TupleData
}

type ServerModeType

type ServerModeType uint8

ServerModeType - тип используемый для описания режима работы инстанса. см. ниже

const (
	ModeMaster ServerModeType = iota
	ModeReplica
)

Режим работы конкретного инстанса. Мастер или реплика. При селекте из реплики быдет выставляться флаг readonly. Более подробно можно прочитать в доке.

type TupleData

type TupleData struct {
	Cnt  uint32
	Data [][]byte
}

func CallLua

func CallLua(ctx context.Context, connection *Connection, name string, args ...string) ([]TupleData, error)

CallLua - функция для вызова lua процедур. В будущем надо будет сделать возможность декларативно описывать процедуры в модели и в сгенерированном коде вызывать эту функцию. Так же надо будет сделать возможность описывать формат для результата в произвольной форме, а не в форме тупла для мочёдели.

func ProcessResp

func ProcessResp(respBytes []byte, cntFlag CountFlags) ([]TupleData, error)

type UpdateMockFixture added in v1.7.0

type UpdateMockFixture struct {
	PrimaryKey [][]byte
	UpdateOps  []Ops
}

Jump to

Keyboard shortcuts

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