fluxaorm

package module
v1.22.4 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 37 Imported by: 0

README

FLUXA ORM

Golang ORM designed for optimal performance with MySQL and Redis 8.0 (Redis Search Engine)

Official documentation

Documentation

Index

Constants

View Source
const DefaultPoolCode = "default"
View Source
const LazyChannelName = "orm-lazy-channel"
View Source
const LazyErrorsChannelName = "orm-lazy-errors-channel"
View Source
const LogChannelName = "orm-log-channel"
View Source
const MetricsMetaKey = "MetrictMetaKey"

Variables

This section is empty.

Functions

func Copy

func Copy[E any](ctx Context, source E) E

func DeleteEntity

func DeleteEntity[E any](ctx Context, source *E)

func EditEntity

func EditEntity[E any](ctx Context, source *E) *E

func EditEntityField

func EditEntityField(ctx Context, entity any, field string, value any) error

func Generate added in v1.21.3

func Generate(engine Engine, outputDirectory string) error

func GetByID

func GetByID[E any, I ID](ctx Context, id I) (entity *E, found bool, err error)

func GetByUniqueIndex

func GetByUniqueIndex[E any](ctx Context, index UniqueIndexDefinition, attributes ...any) (entity *E, found bool, err error)

func GetEntityField

func GetEntityField(ctx Context, entity any, field string) (any, error)

func GetEntityFieldDefinition

func GetEntityFieldDefinition[E any](ctx Context, field string) (t reflect.Type, tags map[string]string, err error)

func GetEntityFields

func GetEntityFields(ctx Context, entity any, field ...string) (map[string]any, error)

func NewEntity

func NewEntity[E any](ctx Context) *E

func NewEntityFromSource added in v1.8.0

func NewEntityFromSource(ctx Context, entity any)

func NewEntityWithID

func NewEntityWithID[E any, I ID](ctx Context, id I) *E

func PushDirty added in v1.21.3

func PushDirty[E any](ctx Context, entities ...E) error

func RedisSearchIDs

func RedisSearchIDs[E any](ctx Context, query *RedisSearchQuery, pager *Pager) (results []uint64, totalRows int, err error)

func RedisSearchOne

func RedisSearchOne[E any](ctx Context, query *RedisSearchQuery) (entity *E, found bool, err error)

func SearchIDs

func SearchIDs[E any](ctx Context, where Where, pager *Pager) ([]uint64, error)

func SearchIDsWithCount

func SearchIDsWithCount[E any](ctx Context, where Where, pager *Pager) (results []uint64, totalRows int, err error)

func SearchOne

func SearchOne[E any](ctx Context, where Where) (entity *E, found bool, err error)

Types

type Alter

type Alter struct {
	SQL  string
	Safe bool
	Pool string
}

func GetAlters

func GetAlters(ctx Context) (alters []Alter, err error)

func (Alter) Exec

func (a Alter) Exec(ctx Context) error

type BaseWhere

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

func NewWhere

func NewWhere(query string, parameters ...any) *BaseWhere

func (*BaseWhere) Append

func (w *BaseWhere) Append(query string, parameters ...any)

func (*BaseWhere) GetParameters

func (w *BaseWhere) GetParameters() []any

func (*BaseWhere) SetParameter

func (w *BaseWhere) SetParameter(index int, param any) *BaseWhere

func (*BaseWhere) SetParameters

func (w *BaseWhere) SetParameters(params ...any) *BaseWhere

func (*BaseWhere) String

func (w *BaseWhere) String() string

func (*BaseWhere) WithFakeDeletes added in v1.15.0

func (w *BaseWhere) WithFakeDeletes() *BaseWhere

type Bind

type Bind map[string]any

func IsDirty

func IsDirty[E any, I ID](ctx Context, id I) (oldValues, newValues Bind, hasChanges bool)

func (Bind) Get

func (b Bind) Get(key string) any

type BindError

type BindError struct {
	Field   string
	Message string
}

func (*BindError) Error

func (b *BindError) Error() string

type ColumnSchemaDefinition

type ColumnSchemaDefinition struct {
	ColumnName string
	Definition string
}

type Config added in v1.16.1

type Config struct {
	MySQlPools         []ConfigMysql         `yaml:"mysqlPools"`
	RedisPools         []ConfigRedis         `yaml:"redisPools"`
	RedisSentinelPools []ConfigRedisSentinel `yaml:"redisSentinelPools"`
	LocalCachePools    []ConfigLocalCache    `yaml:"localCachePools"`
}

type ConfigLocalCache added in v1.16.1

type ConfigLocalCache struct {
	Code  string `yaml:"code" validate:"required"`
	Limit int    `yaml:"limit" validate:"required"`
}

type ConfigMysql added in v1.16.1

type ConfigMysql struct {
	Code               string   `yaml:"code" validate:"required"`
	URI                string   `yaml:"uri" validate:"required"`
	ConnMaxLifetime    int      `yaml:"connMaxLifetime"`
	MaxOpenConnections int      `yaml:"maxOpenConnections"`
	MaxIdleConnections int      `yaml:"maxIdleConnections"`
	DefaultEncoding    string   `yaml:"defaultEncoding"`
	DefaultCollate     string   `yaml:"defaultCollate"`
	IgnoredTables      []string `yaml:"ignoredTables"`
}

type ConfigRedis added in v1.16.1

type ConfigRedis struct {
	Code     string   `yaml:"code" validate:"required"`
	URI      string   `yaml:"uri" validate:"required"`
	Database int      `yaml:"database"`
	User     string   `yaml:"user"`
	Password string   `yaml:"password"`
	Streams  []string `yaml:"streams"`
}

type ConfigRedisSentinel added in v1.16.1

type ConfigRedisSentinel struct {
	Code       string   `yaml:"code" validate:"required"`
	MasterName string   `yaml:"masterName" validate:"required"`
	Database   int      `yaml:"database"`
	Sentinels  []string `yaml:"sentinels"`
	User       string   `yaml:"user"`
	Password   string   `yaml:"password"`
	Streams    []string `yaml:"streams"`
}

type Context

type Context interface {
	Context() context.Context
	Clone() Context
	CloneWithContext(context context.Context) Context
	Engine() Engine
	NewEntity(entity any)
	EditEntity(entity any) any
	DeleteEntity(entity any)
	ForceDeleteEntity(entity any)
	PushDirty(entities ...any) error
	ClearCache()
	EnableContextCache()
	Flush() error
	FlushAsync() error
	ClearFlush()
	RedisPipeLine(pool string) *RedisPipeLine
	DatabasePipeLine(pool string) *DatabasePipeline
	RegisterQueryLogger(handler LogHandler, mysql, redis, local bool)
	EnableQueryDebug()
	EnableQueryDebugCustom(mysql, redis, local bool)
	SetMetaData(key, value string)
	GetMetaData() Meta

	Track(f Flushable, cacheIndex uint64)
	GetEventBroker() EventBroker
	// contains filtered or unexported methods
}

func PrepareTables

func PrepareTables(t *testing.T, registry Registry, entities ...any) (orm Context)

func PrepareTablesBeta added in v1.22.4

func PrepareTablesBeta(t *testing.T, registry Registry, entities ...any) (orm Context)

type DB

type DB interface {
	DBBase
	Begin(ctx Context) (DBTransaction, error)
}

type DBBase

type DBBase interface {
	GetConfig() MySQLConfig
	GetDBClient() DBClient
	SetMockDBClient(mock DBClient)
	Exec(ctx Context, query string, args ...any) (ExecResult, error)
	QueryRow(ctx Context, query Where, toFill ...any) (found bool, err error)
	Query(ctx Context, query string, args ...any) (rows Rows, close func(), err error)
}

type DBClient

type DBClient interface {
	DBClientQuery
}

type DBClientNoTX

type DBClientNoTX interface {
	DBClientQuery
	Begin() (*sql.Tx, error)
}

type DBClientQuery

type DBClientQuery interface {
	Exec(query string, args ...any) (sql.Result, error)
	ExecContext(context context.Context, query string, args ...any) (sql.Result, error)
	QueryRow(query string, args ...any) *sql.Row
	QueryRowContext(context context.Context, query string, args ...any) *sql.Row
	Query(query string, args ...any) (*sql.Rows, error)
	QueryContext(context context.Context, query string, args ...any) (*sql.Rows, error)
}

type DBTransaction

type DBTransaction interface {
	DBBase
	Commit(ctx Context) error
	Rollback(ctx Context) error
}

type DatabasePipeline added in v1.22.3

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

func (*DatabasePipeline) AddQuery added in v1.22.3

func (dp *DatabasePipeline) AddQuery(query string, parameters ...any)

func (*DatabasePipeline) Exec added in v1.22.3

func (dp *DatabasePipeline) Exec(ctx Context) error

type DirtyStreamConsumer added in v1.17.0

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

func NewDirtyStreamConsumerMany added in v1.19.0

func NewDirtyStreamConsumerMany(ctx Context, stream string, handler DirtyStreamEventHandler) (*DirtyStreamConsumer, error)

func NewDirtyStreamConsumerSingle added in v1.19.0

func NewDirtyStreamConsumerSingle(ctx Context, stream string, handler DirtyStreamEventHandler) (*DirtyStreamConsumer, error)

func (*DirtyStreamConsumer) AutoClaim added in v1.19.0

func (r *DirtyStreamConsumer) AutoClaim(count int, minIdle time.Duration) error

func (*DirtyStreamConsumer) Cleanup added in v1.19.0

func (r *DirtyStreamConsumer) Cleanup() error

func (*DirtyStreamConsumer) Consume added in v1.19.0

func (r *DirtyStreamConsumer) Consume(count int, blockTime time.Duration) error

type DirtyStreamEvent added in v1.17.0

type DirtyStreamEvent struct {
	EntityName string
	ID         uint64
	Operation  FlushType
	Bind       Bind
	// contains filtered or unexported fields
}

func (*DirtyStreamEvent) ACK added in v1.17.0

func (ds *DirtyStreamEvent) ACK() error

type DirtyStreamEventHandler added in v1.17.0

type DirtyStreamEventHandler func(events []*DirtyStreamEvent)

type DuplicateKeyError added in v1.8.3

type DuplicateKeyError struct {
	Message string
	Index   string
}

func (*DuplicateKeyError) Error added in v1.8.3

func (e *DuplicateKeyError) Error() string

type Engine

type Engine interface {
	NewContext(parent context.Context) Context
	DB(code string) DB
	LocalCache(code string) LocalCache
	Redis(code string) RedisCache
	Registry() EngineRegistry
	Option(key string) any
	GetRedisStreams() map[string]map[string]string
}

type EngineRegistry

type EngineRegistry interface {
	EntitySchema(entity any) EntitySchema
	DBPools() map[string]DB
	LocalCachePools() map[string]LocalCache
	RedisPools() map[string]RedisCache
	Entities() []EntitySchema
	Option(key string) any
	Enums() map[string][]string
	DisableLogTables()
	// contains filtered or unexported methods
}

type EngineSetter

type EngineSetter interface {
	SetOption(key string, value any)
}

type EntityAnonymousIterator

type EntityAnonymousIterator interface {
	Next() bool
	ID() uint64
	Index() int

	Len() int
	All() ([]any, error)
	AllIDs() ([]uint64, error)
	Entity() (any, error)
	Reset()
	LoadReference(columns ...string) error
	// contains filtered or unexported methods
}

type EntityFlush

type EntityFlush interface {
	ID() uint64
	Schema() *entitySchema
	// contains filtered or unexported methods
}

type EntityFlushedEvent

type EntityFlushedEvent interface {
	FlushType() FlushType
}

type EntityIterator

type EntityIterator[E any] interface {
	Next() bool
	ID() uint64
	Index() int
	Len() int
	Entity() (*E, error)
	All() ([]*E, error)
	AllIDs() ([]uint64, error)
	Reset()
	LoadReference(columns ...string) error
	// contains filtered or unexported methods
}

func GetAll

func GetAll[E any](ctx Context) (EntityIterator[E], error)

func GetByIDs

func GetByIDs[E any](ctx Context, ids ...uint64) (EntityIterator[E], error)

func GetByIndex

func GetByIndex[E any](ctx Context, pager *Pager, index IndexDefinition, attributes ...any) (EntityIterator[E], error)

func GetByIndexWithCount added in v1.16.3

func GetByIndexWithCount[E any](ctx Context, pager *Pager, index IndexDefinition, attributes ...any) (res EntityIterator[E], total int, err error)

func RedisSearch

func RedisSearch[E any](ctx Context, query *RedisSearchQuery, pager *Pager) (results EntityIterator[E], totalRows int, err error)
func Search[E any](ctx Context, where Where, pager *Pager) (EntityIterator[E], error)

func SearchWithCount

func SearchWithCount[E any](ctx Context, where Where, pager *Pager) (results EntityIterator[E], totalRows int, err error)

type EntitySchema

type EntitySchema interface {
	EntitySchemaShared
	DropTable(ctx Context) error
	TruncateTable(ctx Context) error
	UpdateSchema(ctx Context) error
	UpdateSchemaAndTruncateTable(ctx Context) error
	GetSchemaChanges(ctx Context) (alters []Alter, has bool, err error)
	DisableCache(local, redis bool)
	NewEntity(ctx Context) any
	GetByID(ctx Context, id uint64) (entity any, found bool, err error)
	GetByIDs(ctx Context, ids ...uint64) (EntityAnonymousIterator, error)
	Search(ctx Context, where Where, pager *Pager) (EntityAnonymousIterator, error)
	SearchWithCount(ctx Context, where Where, pager *Pager) (results EntityAnonymousIterator, totalRows int, err error)
	SearchIDs(ctx Context, where Where, pager *Pager) ([]uint64, error)
	SearchIDsWithCount(ctx Context, where Where, pager *Pager) (results []uint64, totalRows int, err error)
	IsDirty(ctx Context, id uint64) (oldValues, newValues Bind, hasChanges bool)
	Copy(ctx Context, source any) any
	EditEntityField(ctx Context, entity any, field string, value any) error
	EditEntity(ctx Context, entity any) any
	DeleteEntity(ctx Context, entity any)

	ReindexRedisIndex(ctx Context) error
	ClearCache(ctx Context) (int, error)
	// contains filtered or unexported methods
}

func GetEntitySchema

func GetEntitySchema[E any](ctx Context) EntitySchema

type EntitySchemaSetter

type EntitySchemaSetter interface {
	SetOption(key string, value any)
	EntitySchemaShared
}

type EntitySchemaShared

type EntitySchemaShared interface {
	GetTableName() string
	IsVirtual() bool
	GetType() reflect.Type
	GetColumns() []string
	GetTag(field, key, trueValue, defaultValue string) string
	Option(key string) any
	GetUniqueIndexes() map[string][]string
	GetDB() DB
	GetLocalCache() (cache LocalCache, has bool)
	GetRedisCache() (cache RedisCache, has bool)
	GetRedisSearchPoolCode() string
	GetRedisSearchIndexName() string
}

type EnumValues

type EnumValues interface {
	EnumValues() any
}

type Event added in v1.10.0

type Event interface {
	Ack() error
	ID() string
	Tag(key string) (value string)
	Unserialize(val interface{}) error
}

type EventBroker added in v1.10.0

type EventBroker interface {
	Publish(stream string, body interface{}, meta ...string) (id string, err error)
	ConsumerSingle(ctx Context, stream string) (EventsConsumer, error)
	ConsumerMany(ctx Context, stream string) (EventsConsumer, error)
	NewFlusher() EventFlusher
	GetStreamsStatistics(stream ...string) ([]*RedisStreamStatistics, error)
	GetStreamStatistics(stream string) (*RedisStreamStatistics, error)
}

type EventConsumerHandler added in v1.10.0

type EventConsumerHandler func([]Event) error

type EventFlusher added in v1.10.0

type EventFlusher interface {
	Publish(stream string, body interface{}, meta ...string) error
	Flush() error
}

type EventsConsumer added in v1.10.0

type EventsConsumer interface {
	Consume(count int, blockTime time.Duration, handler EventConsumerHandler) error
	AutoClaim(count int, minIdle time.Duration, handler EventConsumerHandler) error
	Cleanup() error
	Name() string
}

type ExecResult

type ExecResult interface {
	LastInsertId() (uint64, error)
	RowsAffected() (uint64, error)
}

type FlushType

type FlushType int
const (
	Insert FlushType = iota
	Update
	Delete
)

type Flushable added in v1.22.3

type Flushable interface {
	PrivateFlush() error
	PrivateFlushed()
	GetID() uint64
}

type ID

type ID interface {
	int | uint | uint8 | uint16 | uint32 | uint64 | int8 | int16 | int32 | int64
}

type IDGetter

type IDGetter interface {
	GetID() uint64
}

type IndexDefinition added in v1.21.0

type IndexDefinition struct {
	Columns string
	Cached  bool
}

type IndexInterface added in v1.21.0

type IndexInterface interface {
	Indexes() any
}

type IndexSchemaDefinition

type IndexSchemaDefinition struct {
	Name       string
	Unique     bool
	Duplicated bool
	// contains filtered or unexported fields
}

func (*IndexSchemaDefinition) GetColumns

func (ti *IndexSchemaDefinition) GetColumns() []string

func (*IndexSchemaDefinition) SetColumns

func (ti *IndexSchemaDefinition) SetColumns(columns []string)

type LazyFlashConsumer added in v1.17.0

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

func NewLazyFlashConsumer added in v1.17.0

func NewLazyFlashConsumer(ctx Context) *LazyFlashConsumer

func (*LazyFlashConsumer) Consume added in v1.19.0

func (r *LazyFlashConsumer) Consume(blockTime time.Duration) error

type LocalCache

type LocalCache interface {
	Set(ctx Context, key string, value any)
	Remove(ctx Context, key string)
	GetConfig() LocalCacheConfig
	Get(ctx Context, key string) (value any, ok bool)
	Clear(ctx Context)
	GetUsage() []LocalCacheUsage
	// contains filtered or unexported methods
}

type LocalCacheConfig

type LocalCacheConfig interface {
	GetCode() string
	GetLimit() int
	GetSchema() EntitySchema
}

type LocalCacheUsage

type LocalCacheUsage struct {
	Type      string
	Limit     uint64
	Used      uint64
	Evictions uint64
}

type Lock

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

func (*Lock) Refresh

func (l *Lock) Refresh(ctx Context, ttl time.Duration) (bool, error)

func (*Lock) Release

func (l *Lock) Release(ctx Context)

func (*Lock) TTL

func (l *Lock) TTL(ctx Context) (time.Duration, error)

type Locker

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

func (*Locker) Obtain

func (l *Locker) Obtain(ctx Context, key string, ttl time.Duration, waitTimeout time.Duration) (lock *Lock, obtained bool, err error)

type LogEntity

type LogEntity[Entity any] struct {
	ID       uint64
	EntityID uint64
	Date     time.Time `orm:"time"`
	Meta     []byte
	Before   []byte
	After    []byte
}

type LogHandler

type LogHandler interface {
	Handle(ctx Context, log map[string]any)
}

type LogQueueValue added in v1.10.0

type LogQueueValue struct {
	PoolName  string
	TableName string
	ID        uint64
	LogID     uint64
	Meta      map[string]interface{}
	Before    map[string]interface{}
	Changes   map[string]interface{}
	Updated   time.Time
}

type LogTablesConsumer added in v1.17.0

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

func NewLogTablesConsumerMany added in v1.19.0

func NewLogTablesConsumerMany(ctx Context) *LogTablesConsumer

func NewLogTablesConsumerSingle added in v1.19.0

func NewLogTablesConsumerSingle(ctx Context) *LogTablesConsumer

func (*LogTablesConsumer) AutoClaim added in v1.19.0

func (r *LogTablesConsumer) AutoClaim(count int, minIdle time.Duration) error

func (*LogTablesConsumer) Cleanup added in v1.19.0

func (r *LogTablesConsumer) Cleanup() error

func (*LogTablesConsumer) Consume added in v1.19.0

func (r *LogTablesConsumer) Consume(count int, blockTime time.Duration) error

type Meta

type Meta map[string]string

func (Meta) Get

func (m Meta) Get(key string) string

type MockDBClient

type MockDBClient struct {
	OriginDB            DBClient
	PrepareMock         func(query string) (*sql.Stmt, error)
	ExecMock            func(query string, args ...any) (sql.Result, error)
	ExecContextMock     func(context context.Context, query string, args ...any) (sql.Result, error)
	QueryRowMock        func(query string, args ...any) *sql.Row
	QueryRowContextMock func(context context.Context, query string, args ...any) *sql.Row
	QueryMock           func(query string, args ...any) (*sql.Rows, error)
	QueryContextMock    func(context context.Context, query string, args ...any) (*sql.Rows, error)
	BeginMock           func() (*sql.Tx, error)
	CommitMock          func() error
	RollbackMock        func() error
}

func (*MockDBClient) Exec

func (m *MockDBClient) Exec(query string, args ...any) (sql.Result, error)

func (*MockDBClient) ExecContext

func (m *MockDBClient) ExecContext(context context.Context, query string, args ...any) (sql.Result, error)

func (*MockDBClient) Query

func (m *MockDBClient) Query(query string, args ...any) (*sql.Rows, error)

func (*MockDBClient) QueryContext

func (m *MockDBClient) QueryContext(context context.Context, query string, args ...any) (*sql.Rows, error)

func (*MockDBClient) QueryRow

func (m *MockDBClient) QueryRow(query string, args ...any) *sql.Row

func (*MockDBClient) QueryRowContext

func (m *MockDBClient) QueryRowContext(context context.Context, query string, args ...any) *sql.Row

type MockLogHandler

type MockLogHandler struct {
	Logs []map[string]any
}

func (*MockLogHandler) Clear

func (h *MockLogHandler) Clear()

func (*MockLogHandler) Handle

func (h *MockLogHandler) Handle(_ Context, log map[string]any)

type MySQLConfig

type MySQLConfig interface {
	GetCode() string
	GetDatabaseName() string
	GetDataSourceURI() string
	GetOptions() *MySQLOptions
	// contains filtered or unexported methods
}

type MySQLOptions

type MySQLOptions struct {
	ConnMaxLifetime    time.Duration
	MaxOpenConnections int
	MaxIdleConnections int
	DefaultEncoding    string
	DefaultCollate     string
	IgnoredTables      []string
	Beta               bool
}

type Pager

type Pager struct {
	CurrentPage int
	PageSize    int
}

func NewPager

func NewPager(currentPage, pageSize int) *Pager

func (*Pager) GetCurrentPage

func (pager *Pager) GetCurrentPage() int

func (*Pager) GetPageSize

func (pager *Pager) GetPageSize() int

func (*Pager) IncrementPage

func (pager *Pager) IncrementPage()

func (*Pager) String

func (pager *Pager) String() string

type PipeLineBool

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

func (*PipeLineBool) Result

func (c *PipeLineBool) Result() (bool, error)

type PipeLineGet

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

func (*PipeLineGet) Result

func (c *PipeLineGet) Result() (value string, has bool, err error)

type PipeLineInt

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

func (*PipeLineInt) Result

func (c *PipeLineInt) Result() (int64, error)

type PipeLineSlice

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

func (*PipeLineSlice) Result

func (c *PipeLineSlice) Result() ([]string, error)

type PipeLineString

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

func (*PipeLineString) Result

func (c *PipeLineString) Result() (string, error)

type PluginInitNewEntity added in v1.17.4

type PluginInitNewEntity interface {
	InitNewEntity(schema EntitySchema, entity reflect.Value)
}

type PluginInterfaceEntityFlush

type PluginInterfaceEntityFlush interface {
	EntityFlush(schema EntitySchema, entity reflect.Value, id uint64, before, after Bind, engine Engine) (PostFlushAction, error)
}

type PluginInterfaceInitRegistryFromYaml

type PluginInterfaceInitRegistryFromYaml interface {
	InitRegistryFromYaml(registry Registry, yaml map[string]any) error
}

type PluginInterfaceValidateEntitySchema

type PluginInterfaceValidateEntitySchema interface {
	ValidateEntitySchema(schema EntitySchemaSetter) error
}

type PluginInterfaceValidateRegistry

type PluginInterfaceValidateRegistry interface {
	ValidateRegistry(engine EngineSetter, registry Registry) error
}

type PostFlushAction

type PostFlushAction func(ctx Context)

type QueryLoggerSource

type QueryLoggerSource int

type RedisCache

type RedisCache interface {
	Set(ctx Context, key string, value any, expiration time.Duration) error
	MSet(ctx Context, pairs ...any) error
	Del(ctx Context, keys ...string) error
	HSet(ctx Context, key string, values ...any) error
	HDel(ctx Context, key string, keys ...string) error
	GetSet(ctx Context, key string, expiration time.Duration, provider func() any) (any, error)
	Info(ctx Context, section ...string) (string, error)
	GetConfig() RedisPoolConfig
	Get(ctx Context, key string) (value string, has bool, err error)
	Eval(ctx Context, script string, keys []string, args ...any) (any, error)
	EvalSha(ctx Context, sha1 string, keys []string, args ...any) (res any, exists bool, err error)
	SetNX(ctx Context, key string, value any, expiration time.Duration) (bool, error)
	ScriptExists(ctx Context, sha1 string) (bool, error)
	ScriptLoad(ctx Context, script string) (string, error)
	LPush(ctx Context, key string, values ...any) (int64, error)
	LPop(ctx Context, key string) (string, error)
	RPush(ctx Context, key string, values ...any) (int64, error)
	LLen(ctx Context, key string) (int64, error)
	Exists(ctx Context, keys ...string) (int64, error)
	Type(ctx Context, key string) (string, error)
	LRange(ctx Context, key string, start, stop int64) ([]string, error)
	LIndex(ctx Context, key string, index int64) (string, bool, error)
	LSet(ctx Context, key string, index int64, value any) error
	RPop(ctx Context, key string) (value string, found bool, err error)
	BLMove(ctx Context, source, destination, srcPos, destPos string, timeout time.Duration) (string, error)
	LMove(ctx Context, source, destination, srcPos, destPos string) (string, error)
	LRem(ctx Context, key string, count int64, value any) error
	Ltrim(ctx Context, key string, start, stop int64) error
	HSetNx(ctx Context, key, field string, value any) (bool, error)
	HMGet(ctx Context, key string, fields ...string) (map[string]any, error)
	HGetAll(ctx Context, key string) (map[string]string, error)
	HGet(ctx Context, key, field string) (value string, has bool, err error)
	HLen(ctx Context, key string) (int64, error)
	HIncrBy(ctx Context, key, field string, incr int64) (int64, error)
	IncrBy(ctx Context, key string, incr int64) (int64, error)
	Incr(ctx Context, key string) (int64, error)
	IncrWithExpire(ctx Context, key string, expire time.Duration) (int64, error)
	Expire(ctx Context, key string, expiration time.Duration) (bool, error)
	ZAdd(ctx Context, key string, members ...redis.Z) (int64, error)
	ZRevRange(ctx Context, key string, start, stop int64) ([]string, error)
	ZRevRangeWithScores(ctx Context, key string, start, stop int64) ([]redis.Z, error)
	ZRangeWithScores(ctx Context, key string, start, stop int64) ([]redis.Z, error)
	ZRangeArgsWithScores(ctx Context, z redis.ZRangeArgs) ([]redis.Z, error)
	ZCard(ctx Context, key string) (int64, error)
	ZCount(ctx Context, key string, min, max string) (int64, error)
	ZScore(ctx Context, key, member string) (float64, error)
	MGet(ctx Context, keys ...string) ([]any, error)
	SAdd(ctx Context, key string, members ...any) (int64, error)
	SMembers(ctx Context, key string) ([]string, error)
	SIsMember(ctx Context, key string, member any) (bool, error)
	SCard(ctx Context, key string) (int64, error)
	SPop(ctx Context, key string) (string, bool, error)
	SPopN(ctx Context, key string, max int64) ([]string, error)
	XTrim(ctx Context, stream string, maxLen int64) (deleted int64, err error)
	XRange(ctx Context, stream, start, stop string, count int64) ([]redis.XMessage, error)
	XRevRange(ctx Context, stream, start, stop string, count int64) ([]redis.XMessage, error)
	XInfoStream(ctx Context, stream string) (*redis.XInfoStream, error)
	XInfoGroups(ctx Context, stream string) ([]redis.XInfoGroup, error)
	XGroupCreate(ctx Context, stream, group, start string) (key string, exists bool, err error)
	XGroupCreateMkStream(ctx Context, stream, group, start string) (key string, exists bool, err error)
	XGroupDestroy(ctx Context, stream, group string) (int64, error)
	XRead(ctx Context, a *redis.XReadArgs) ([]redis.XStream, error)
	XDel(ctx Context, stream string, ids ...string) (int64, error)
	XAutoClaim(ctx Context, a *redis.XAutoClaimArgs) (messages []redis.XMessage, start string, err error)
	XGroupDelConsumer(ctx Context, stream, group, consumer string) (int64, error)
	XReadGroup(ctx Context, a *redis.XReadGroupArgs) (streams []redis.XStream, err error)
	XPending(ctx Context, stream, group string) (*redis.XPending, error)
	XPendingExt(ctx Context, a *redis.XPendingExtArgs) ([]redis.XPendingExt, error)
	XLen(ctx Context, stream string) (int64, error)
	XClaim(ctx Context, a *redis.XClaimArgs) ([]redis.XMessage, error)
	XClaimJustID(ctx Context, a *redis.XClaimArgs) ([]string, error)
	XAck(ctx Context, stream, group string, ids ...string) (int64, error)

	FlushAll(ctx Context) error
	FlushDB(ctx Context) error
	Scan(ctx Context, cursor uint64, match string, count int64) (keys []string, cursorNext uint64, err error)
	GetLocker() *Locker
	GetCode() string
	FTList(ctx Context) ([]string, error)
	FTDrop(ctx Context, index string, dropDocuments bool) error
	FTSearch(ctx Context, index string, query string, options *redis.FTSearchOptions) (redis.FTSearchResult, error)
	FTCreate(ctx Context, index string, options *redis.FTCreateOptions, schema ...*redis.FieldSchema) error
	FTInfo(ctx Context, index string) (info *redis.FTInfoResult, found bool, err error)
	Client() *redis.Client
	// contains filtered or unexported methods
}

type RedisOptions

type RedisOptions struct {
	User            string
	Password        string
	Master          string
	Sentinels       []string
	SentinelOptions *redis.FailoverOptions
}

type RedisPipeLine

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

func (*RedisPipeLine) Del

func (rp *RedisPipeLine) Del(key ...string)

func (*RedisPipeLine) Exec

func (rp *RedisPipeLine) Exec(ctx Context) (response []redis.Cmder, err error)

func (*RedisPipeLine) Expire

func (rp *RedisPipeLine) Expire(key string, expiration time.Duration) *PipeLineBool

func (*RedisPipeLine) Get

func (rp *RedisPipeLine) Get(key string) *PipeLineGet

func (*RedisPipeLine) HDel

func (rp *RedisPipeLine) HDel(key string, values ...string)

func (*RedisPipeLine) HIncrBy

func (rp *RedisPipeLine) HIncrBy(key, field string, incr int64) *PipeLineInt

func (*RedisPipeLine) HSet

func (rp *RedisPipeLine) HSet(key string, values ...any)

func (*RedisPipeLine) LPush

func (rp *RedisPipeLine) LPush(key string, values ...any)

func (*RedisPipeLine) LRange

func (rp *RedisPipeLine) LRange(key string, start, stop int64) *PipeLineSlice

func (*RedisPipeLine) LSet

func (rp *RedisPipeLine) LSet(key string, index int64, value any)

func (*RedisPipeLine) MSet

func (rp *RedisPipeLine) MSet(pairs ...any)

func (*RedisPipeLine) RPush

func (rp *RedisPipeLine) RPush(key string, values ...any)

func (*RedisPipeLine) SAdd

func (rp *RedisPipeLine) SAdd(key string, members ...any)

func (*RedisPipeLine) SRem

func (rp *RedisPipeLine) SRem(key string, members ...any)

func (*RedisPipeLine) Set

func (rp *RedisPipeLine) Set(key string, value any, expiration time.Duration)

func (*RedisPipeLine) XAdd

func (rp *RedisPipeLine) XAdd(stream string, values []string) *PipeLineString

type RedisPoolConfig

type RedisPoolConfig interface {
	GetCode() string
	GetDatabaseNumber() int
	GetAddress() string
	// contains filtered or unexported methods
}

type RedisSearchAlter

type RedisSearchAlter struct {
	IndexName       string
	DocumentsInDB   uint64
	Pool            string
	Drop            bool
	IndexDefinition string
	// contains filtered or unexported fields
}

func GetRedisSearchAlters

func GetRedisSearchAlters(ctx Context) (alters []RedisSearchAlter, err error)

func (RedisSearchAlter) Exec

func (a RedisSearchAlter) Exec(ctx Context) error

type RedisSearchFilter

type RedisSearchFilter struct {
	FieldName string
	Min       any
	Max       any
}

type RedisSearchQuery added in v1.16.0

type RedisSearchQuery struct {
	Query   string
	SortBy  []RedisSearchSortBy
	Filters []RedisSearchFilter
	Tags    string
}

func NewRedisSearchQuery added in v1.17.5

func NewRedisSearchQuery() *RedisSearchQuery

func (*RedisSearchQuery) AddFilterBoolean added in v1.16.0

func (q *RedisSearchQuery) AddFilterBoolean(fieldName string, value bool)

func (*RedisSearchQuery) AddFilterDate added in v1.16.0

func (q *RedisSearchQuery) AddFilterDate(fieldName string, value time.Time)

func (*RedisSearchQuery) AddFilterDateRange added in v1.16.0

func (q *RedisSearchQuery) AddFilterDateRange(fieldName string, min, max time.Time)

func (*RedisSearchQuery) AddFilterNumber added in v1.16.0

func (q *RedisSearchQuery) AddFilterNumber(fieldName string, value int64)

func (*RedisSearchQuery) AddFilterNumberGreaterEqual added in v1.16.0

func (q *RedisSearchQuery) AddFilterNumberGreaterEqual(fieldName string, value int64)

func (*RedisSearchQuery) AddFilterNumberLessEqual added in v1.16.0

func (q *RedisSearchQuery) AddFilterNumberLessEqual(fieldName string, value int64)

func (*RedisSearchQuery) AddFilterNumberRange added in v1.16.0

func (q *RedisSearchQuery) AddFilterNumberRange(fieldName string, min, max int64)

func (*RedisSearchQuery) AddFilterTag added in v1.16.0

func (q *RedisSearchQuery) AddFilterTag(fieldName string, tag ...string)

func (*RedisSearchQuery) AddSortBy added in v1.16.0

func (q *RedisSearchQuery) AddSortBy(fieldName string, desc bool)

type RedisSearchSortBy

type RedisSearchSortBy struct {
	FieldName string
	Desc      bool
}

type RedisStreamConsumerStatistics added in v1.10.0

type RedisStreamConsumerStatistics struct {
	Name    string
	Pending uint64
}

type RedisStreamGroupStatistics added in v1.10.0

type RedisStreamGroupStatistics struct {
	Group                 string
	Lag                   int64
	Pending               uint64
	LastDeliveredID       string
	LastDeliveredDuration time.Duration
	LowerID               string
	LowerDuration         time.Duration
	Consumers             []*RedisStreamConsumerStatistics
}

type RedisStreamStatistics added in v1.10.0

type RedisStreamStatistics struct {
	Stream             string
	RedisPool          string
	Len                uint64
	OldestEventSeconds int
	Group              *RedisStreamGroupStatistics
}

type Reference

type Reference[E any] uint64

func (Reference[E]) GetEntity

func (r Reference[E]) GetEntity(ctx Context) (*E, error)

func (Reference[E]) GetID

func (r Reference[E]) GetID() uint64

func (Reference[E]) Schema

func (r Reference[E]) Schema(ctx Context) EntitySchema

type ReferenceInterface

type ReferenceInterface interface {
	IDGetter
	Schema(ctx Context) EntitySchema
	// contains filtered or unexported methods
}

type References added in v1.13.5

type References[E any] struct {
	// contains filtered or unexported fields
}

func (*References[E]) GetEntities added in v1.13.5

func (r *References[E]) GetEntities(ctx Context) (EntityIterator[E], error)

func (*References[E]) GetEntity added in v1.13.5

func (r *References[E]) GetEntity(ctx Context, index int) (*E, error)

func (*References[E]) GetIDs added in v1.13.5

func (r *References[E]) GetIDs() []uint64

func (*References[E]) Len added in v1.13.5

func (r *References[E]) Len() int

func (*References[E]) SetIDs added in v1.13.5

func (r *References[E]) SetIDs(ids []uint64)

type Registry

type Registry interface {
	Validate() (Engine, error)
	RegisterEntity(entity ...any)
	RegisterPlugin(plugin ...any)
	RegisterMySQL(dataSourceName string, poolCode string, poolOptions *MySQLOptions)
	RegisterLocalCache(code string, limit int)
	RegisterRedis(address string, db int, poolCode string, options *RedisOptions)
	InitByYaml(yaml any) error
	InitByConfig(config *Config) error
	SetOption(key string, value any)
	RegisterRedisStream(name string, redisPool string)
	EnableMetrics(factory promauto.Factory)
}

func NewRegistry

func NewRegistry() Registry

type Rows

type Rows interface {
	Next() bool
	Scan(dest ...any) error
	Columns() ([]string, error)
}

type SQLRow

type SQLRow interface {
	Scan(dest ...any) error
	Err() error
}

type SQLRows

type SQLRows interface {
	Next() bool
	Err() error
	Close() error
	Scan(dest ...any) error
	Columns() ([]string, error)
}

type Struct added in v1.13.0

type Struct[E any] struct {
	// contains filtered or unexported fields
}

func (*Struct[E]) Get added in v1.13.0

func (r *Struct[E]) Get() *E

func (*Struct[E]) Set added in v1.13.0

func (r *Struct[E]) Set(e *E)

type TXClient

type TXClient interface {
	DBClientQuery
}

type TableSQLSchemaDefinition

type TableSQLSchemaDefinition struct {
	EntitySchema   EntitySchema
	EntityColumns  []*ColumnSchemaDefinition
	EntityIndexes  []*IndexSchemaDefinition
	DBTableColumns []*ColumnSchemaDefinition
	DBIndexes      []*IndexSchemaDefinition
	DBCreateSchema string
	DBEncoding     string
	Engine         string
	PreAlters      []Alter
	PostAlters     []Alter
	// contains filtered or unexported fields
}

func (*TableSQLSchemaDefinition) CreateTableSQL

func (td *TableSQLSchemaDefinition) CreateTableSQL() string

type UniqueIndexDefinition added in v1.21.0

type UniqueIndexDefinition struct {
	Columns string
	Cached  bool
}

type Where

type Where interface {
	String() string
	GetParameters() []any
}

Directories

Path Synopsis
plugins

Jump to

Keyboard shortcuts

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