Documentation ¶
Index ¶
- func FiltrWhere(field field.Expr, value any) field.Expr
- func QueryPaging(query any, page Paging) error
- func SetDsn(m *configs.GormDbConfig) string
- type Aggregator
- func (agt *Aggregator) Enqueue(item interface{}) error
- func (agt *Aggregator) EnqueueWithRetry(item interface{}, maxRetries int, backoff time.Duration) bool
- func (agt *Aggregator) SafeStop()
- func (agt *Aggregator) Start()
- func (agt *Aggregator) Stop()
- func (agt *Aggregator) TryEnqueue(item interface{}) bool
- type AggregatorOption
- type BatchProcessFunc
- type DBConfig
- type DBManager
- type ErrorHandlerFunc
- type Paging
- type SetAggregatorOptionFunc
- func WithBatchSize(batchSize int) SetAggregatorOptionFunc
- func WithChannelBufferSize(size int) SetAggregatorOptionFunc
- func WithErrorHandler(handler ErrorHandlerFunc) SetAggregatorOptionFunc
- func WithLingerTime(duration time.Duration) SetAggregatorOptionFunc
- func WithLogger(logger *log.Logger) SetAggregatorOptionFunc
- func WithWorkers(workers int) SetAggregatorOptionFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func QueryPaging ¶ added in v0.0.4
func SetDsn ¶
func SetDsn(m *configs.GormDbConfig) string
Types ¶
type Aggregator ¶ added in v0.0.4
type Aggregator struct {
// contains filtered or unexported fields
}
Aggregator 聚合器结构体
func NewAggregator ¶ added in v0.0.4
func NewAggregator(batchProcessor BatchProcessFunc, optionFuncs ...SetAggregatorOptionFunc) (*Aggregator, error)
NewAggregator 创建新的聚合器实例
func (*Aggregator) Enqueue ¶ added in v0.0.4
func (agt *Aggregator) Enqueue(item interface{}) error
Enqueue 入队一个项目,会阻塞直到有空间
func (*Aggregator) EnqueueWithRetry ¶ added in v0.0.4
func (agt *Aggregator) EnqueueWithRetry(item interface{}, maxRetries int, backoff time.Duration) bool
EnqueueWithRetry 入队一个项目,会重试直到成功或者达到最大重试次数
func (*Aggregator) SafeStop ¶ added in v0.0.4
func (agt *Aggregator) SafeStop()
SafeStop 安全停止聚合器,确保所有项目都被处理
func (*Aggregator) TryEnqueue ¶ added in v0.0.4
func (agt *Aggregator) TryEnqueue(item interface{}) bool
TryEnqueue 尝试入队一个项目,非阻塞
type AggregatorOption ¶ added in v0.0.4
type AggregatorOption struct { BatchSize int Workers int ChannelBufferSize int LingerTime time.Duration ErrorHandler ErrorHandlerFunc Logger *log.Logger }
AggregatorOption 聚合器选项
type BatchProcessFunc ¶ added in v0.0.4
type BatchProcessFunc func([]interface{}) error
BatchProcessFunc 批处理函数类型
type DBManager ¶
type DBManager struct {
// contains filtered or unexported fields
}
DBManager 数据库管理器
func GetGormDB ¶
func GetGormDB(dbConfig *configs.GormDbConfig) (dbm *DBManager, err error)
GetGormDB 获取gorm.DB
func (*DBManager) ReconnectIfNeeded ¶
ReconnectIfNeeded 检查连接并在需要时重连
func (*DBManager) StartHealthCheck ¶
StartHealthCheck 启动健康检查
type ErrorHandlerFunc ¶ added in v0.0.4
type ErrorHandlerFunc func(err error, items []interface{}, batchProcessFunc BatchProcessFunc, aggregator *Aggregator)
ErrorHandlerFunc 错误处理函数类型
type Paging ¶ added in v0.0.4
type SetAggregatorOptionFunc ¶ added in v0.0.4
type SetAggregatorOptionFunc func(option *AggregatorOption)
SetAggregatorOptionFunc 聚合器选项设置函数类型
func WithBatchSize ¶ added in v0.0.4
func WithBatchSize(batchSize int) SetAggregatorOptionFunc
示例: 设置聚合器选项的函数
func WithChannelBufferSize ¶ added in v0.0.4
func WithChannelBufferSize(size int) SetAggregatorOptionFunc
func WithErrorHandler ¶ added in v0.0.4
func WithErrorHandler(handler ErrorHandlerFunc) SetAggregatorOptionFunc
func WithLingerTime ¶ added in v0.0.4
func WithLingerTime(duration time.Duration) SetAggregatorOptionFunc
func WithLogger ¶ added in v0.0.4
func WithLogger(logger *log.Logger) SetAggregatorOptionFunc
func WithWorkers ¶ added in v0.0.4
func WithWorkers(workers int) SetAggregatorOptionFunc
Click to show internal directories.
Click to hide internal directories.