Documentation
¶
Index ¶
- Constants
- func Copy[E any](ctx Context, source E) E
- func DeleteEntity[E any](ctx Context, source *E)
- func EditEntity[E any](ctx Context, source *E) *E
- func EditEntityField(ctx Context, entity any, field string, value any) error
- func Generate(engine Engine, outputDirectory string) error
- func GetByID[E any, I ID](ctx Context, id I) (entity *E, found bool, err error)
- func GetByUniqueIndex[E any](ctx Context, index UniqueIndexDefinition, attributes ...any) (entity *E, found bool, err error)
- func GetEntityField(ctx Context, entity any, field string) (any, error)
- func GetEntityFieldDefinition[E any](ctx Context, field string) (t reflect.Type, tags map[string]string, err error)
- func GetEntityFields(ctx Context, entity any, field ...string) (map[string]any, error)
- func NewEntity[E any](ctx Context) *E
- func NewEntityFromSource(ctx Context, entity any)
- func NewEntityWithID[E any, I ID](ctx Context, id I) *E
- func PushDirty[E any](ctx Context, entities ...E) error
- func RedisSearchIDs[E any](ctx Context, query *RedisSearchQuery, pager *Pager) (results []uint64, totalRows int, err error)
- func RedisSearchOne[E any](ctx Context, query *RedisSearchQuery) (entity *E, found bool, err error)
- func SearchIDs[E any](ctx Context, where Where, pager *Pager) ([]uint64, error)
- func SearchIDsWithCount[E any](ctx Context, where Where, pager *Pager) (results []uint64, totalRows int, err error)
- func SearchOne[E any](ctx Context, where Where) (entity *E, found bool, err error)
- type Alter
- type BaseWhere
- func (w *BaseWhere) Append(query string, parameters ...any)
- func (w *BaseWhere) GetParameters() []any
- func (w *BaseWhere) SetParameter(index int, param any) *BaseWhere
- func (w *BaseWhere) SetParameters(params ...any) *BaseWhere
- func (w *BaseWhere) String() string
- func (w *BaseWhere) WithFakeDeletes() *BaseWhere
- type Bind
- type BindError
- type ColumnSchemaDefinition
- type Config
- type ConfigLocalCache
- type ConfigMysql
- type ConfigRedis
- type ConfigRedisSentinel
- type Context
- type DB
- type DBBase
- type DBClient
- type DBClientNoTX
- type DBClientQuery
- type DBTransaction
- type DatabasePipeline
- type DirtyStreamConsumer
- type DirtyStreamEvent
- type DirtyStreamEventHandler
- type DuplicateKeyError
- type Engine
- type EngineRegistry
- type EngineSetter
- type EntityAnonymousIterator
- type EntityFlush
- type EntityFlushedEvent
- type EntityIterator
- func GetAll[E any](ctx Context) (EntityIterator[E], error)
- func GetByIDs[E any](ctx Context, ids ...uint64) (EntityIterator[E], error)
- func GetByIndex[E any](ctx Context, pager *Pager, index IndexDefinition, attributes ...any) (EntityIterator[E], error)
- func GetByIndexWithCount[E any](ctx Context, pager *Pager, index IndexDefinition, attributes ...any) (res EntityIterator[E], total int, err error)
- 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[E any](ctx Context, where Where, pager *Pager) (results EntityIterator[E], totalRows int, err error)
- type EntitySchema
- type EntitySchemaSetter
- type EntitySchemaShared
- type EnumValues
- type Event
- type EventBroker
- type EventConsumerHandler
- type EventFlusher
- type EventsConsumer
- type ExecResult
- type FlushType
- type Flushable
- type ID
- type IDGetter
- type IndexDefinition
- type IndexInterface
- type IndexSchemaDefinition
- type LazyFlashConsumer
- type LocalCache
- type LocalCacheConfig
- type LocalCacheUsage
- type Lock
- type Locker
- type LogEntity
- type LogHandler
- type LogQueueValue
- type LogTablesConsumer
- type Meta
- type MockDBClient
- func (m *MockDBClient) Exec(query string, args ...any) (sql.Result, error)
- func (m *MockDBClient) ExecContext(context context.Context, query string, args ...any) (sql.Result, error)
- func (m *MockDBClient) Query(query string, args ...any) (*sql.Rows, error)
- func (m *MockDBClient) QueryContext(context context.Context, query string, args ...any) (*sql.Rows, error)
- func (m *MockDBClient) QueryRow(query string, args ...any) *sql.Row
- func (m *MockDBClient) QueryRowContext(context context.Context, query string, args ...any) *sql.Row
- type MockLogHandler
- type MySQLConfig
- type MySQLOptions
- type Pager
- type PipeLineBool
- type PipeLineGet
- type PipeLineInt
- type PipeLineSlice
- type PipeLineString
- type PluginInitNewEntity
- type PluginInterfaceEntityFlush
- type PluginInterfaceInitRegistryFromYaml
- type PluginInterfaceValidateEntitySchema
- type PluginInterfaceValidateRegistry
- type PostFlushAction
- type QueryLoggerSource
- type RedisCache
- type RedisOptions
- type RedisPipeLine
- func (rp *RedisPipeLine) Del(key ...string)
- func (rp *RedisPipeLine) Exec(ctx Context) (response []redis.Cmder, err error)
- func (rp *RedisPipeLine) Expire(key string, expiration time.Duration) *PipeLineBool
- func (rp *RedisPipeLine) Get(key string) *PipeLineGet
- func (rp *RedisPipeLine) HDel(key string, values ...string)
- func (rp *RedisPipeLine) HIncrBy(key, field string, incr int64) *PipeLineInt
- func (rp *RedisPipeLine) HSet(key string, values ...any)
- func (rp *RedisPipeLine) LPush(key string, values ...any)
- func (rp *RedisPipeLine) LRange(key string, start, stop int64) *PipeLineSlice
- func (rp *RedisPipeLine) LSet(key string, index int64, value any)
- func (rp *RedisPipeLine) MSet(pairs ...any)
- func (rp *RedisPipeLine) RPush(key string, values ...any)
- func (rp *RedisPipeLine) SAdd(key string, members ...any)
- func (rp *RedisPipeLine) SRem(key string, members ...any)
- func (rp *RedisPipeLine) Set(key string, value any, expiration time.Duration)
- func (rp *RedisPipeLine) XAdd(stream string, values []string) *PipeLineString
- type RedisPoolConfig
- type RedisSearchAlter
- type RedisSearchFilter
- type RedisSearchQuery
- func (q *RedisSearchQuery) AddFilterBoolean(fieldName string, value bool)
- func (q *RedisSearchQuery) AddFilterDate(fieldName string, value time.Time)
- func (q *RedisSearchQuery) AddFilterDateRange(fieldName string, min, max time.Time)
- func (q *RedisSearchQuery) AddFilterNumber(fieldName string, value int64)
- func (q *RedisSearchQuery) AddFilterNumberGreaterEqual(fieldName string, value int64)
- func (q *RedisSearchQuery) AddFilterNumberLessEqual(fieldName string, value int64)
- func (q *RedisSearchQuery) AddFilterNumberRange(fieldName string, min, max int64)
- func (q *RedisSearchQuery) AddFilterTag(fieldName string, tag ...string)
- func (q *RedisSearchQuery) AddSortBy(fieldName string, desc bool)
- type RedisSearchSortBy
- type RedisStreamConsumerStatistics
- type RedisStreamGroupStatistics
- type RedisStreamStatistics
- type Reference
- type ReferenceInterface
- type References
- type Registry
- type Rows
- type SQLRow
- type SQLRows
- type Struct
- type TXClient
- type TableSQLSchemaDefinition
- type UniqueIndexDefinition
- type Where
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 DeleteEntity ¶
func EditEntity ¶
func GetByUniqueIndex ¶
func GetEntityFields ¶
func NewEntityFromSource ¶ added in v1.8.0
func NewEntityWithID ¶
func RedisSearchIDs ¶
func RedisSearchOne ¶
func RedisSearchOne[E any](ctx Context, query *RedisSearchQuery) (entity *E, found bool, err error)
func SearchIDsWithCount ¶
Types ¶
type BaseWhere ¶
type BaseWhere struct {
// contains filtered or unexported fields
}
func (*BaseWhere) GetParameters ¶
func (*BaseWhere) SetParameters ¶
func (*BaseWhere) WithFakeDeletes ¶ added in v1.15.0
type ColumnSchemaDefinition ¶
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 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 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 ¶
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 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
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
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 EntityAnonymousIterator ¶
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 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 SearchWithCount ¶
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 {
}
type EnumValues ¶
type EnumValues interface {
EnumValues() any
}
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 EventFlusher ¶ added in v1.10.0
type EventsConsumer ¶ added in v1.10.0
type ExecResult ¶
type IndexDefinition ¶ added in v1.21.0
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
type LocalCache ¶
type LocalCacheConfig ¶
type LocalCacheConfig interface {
GetCode() string
GetLimit() int
GetSchema() EntitySchema
}
type LocalCacheUsage ¶
type LogHandler ¶
type LogQueueValue ¶ added in v1.10.0
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
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) ExecContext ¶
func (*MockDBClient) QueryContext ¶
func (*MockDBClient) QueryRowContext ¶
type MockLogHandler ¶
func (*MockLogHandler) Clear ¶
func (h *MockLogHandler) Clear()
type MySQLConfig ¶
type MySQLConfig interface {
GetCode() string
GetDatabaseName() string
GetDataSourceURI() string
GetOptions() *MySQLOptions
// contains filtered or unexported methods
}
type MySQLOptions ¶
type Pager ¶
func (*Pager) GetCurrentPage ¶
func (*Pager) GetPageSize ¶
func (*Pager) IncrementPage ¶
func (pager *Pager) IncrementPage()
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
}
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 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 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) 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 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 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 RedisStreamConsumerStatistics ¶ added in v1.10.0
type RedisStreamGroupStatistics ¶ added in v1.10.0
type RedisStreamStatistics ¶ added in v1.10.0
type RedisStreamStatistics struct {
Stream string
RedisPool string
Len uint64
OldestEventSeconds int
Group *RedisStreamGroupStatistics
}
type Reference ¶
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 Struct ¶ added in v1.13.0
type Struct[E any] struct { // contains filtered or unexported fields }
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
Source Files
¶
- bind.go
- column_setter.go
- config.go
- copy.go
- database_pipeline.go
- db.go
- dirty_stream_consumer.go
- dirty_stream_push.go
- edit_entity_field.go
- editable_entity.go
- engine.go
- entity_deserialize.go
- entity_iterator.go
- entity_schema.go
- enum.go
- event_broker.go
- flush.go
- generate.go
- get_all.go
- get_by_id.go
- get_by_ids.go
- get_by_index.go
- get_by_unique_index.go
- get_entity_field.go
- lazy_flash_consumer.go
- local_cache.go
- locker.go
- log_table.go
- log_tables_consumer.go
- metrics.go
- orm.go
- pager.go
- plugin.go
- query_logger.go
- redis_cache.go
- redis_pipeline.go
- redis_streams_statistics.go
- reference.go
- references.go
- registry.go
- schema.go
- search.go
- search_by_redis_index.go
- struct.go
- test.go
- utils.go
- where.go
- yaml_loader.go
Click to show internal directories.
Click to hide internal directories.