Documentation
¶
Overview ¶
Package repo 提供消息队列事件表仓储
@author zwei
Package repo 提供消息队列事件表仓储 ¶
@author zwei
Package repo 提供消息队列事件表仓储 ¶
@author zwei
Package repo 提供消息队列事件表仓储 ¶
@author zwei
Index ¶
- type InboxDlqRepo
- func (r *InboxDlqRepo) Delete(ctx context.Context, id int64) error
- func (r *InboxDlqRepo) Fetch(ctx context.Context, serviceName string, size int, now time.Time) ([]model.SysEventInboxDlq, error)
- func (r *InboxDlqRepo) Insert(ctx context.Context, row *model.SysEventInboxDlq) error
- func (r *InboxDlqRepo) UpdateRetry(ctx context.Context, id int64, retryCount int, lastTime time.Time, ...) error
- type InboxRepo
- func (r *InboxRepo) Exists(ctx context.Context, serviceName, eventID string) (bool, error)
- func (r *InboxRepo) Insert(ctx context.Context, row *model.SysEventInbox) error
- func (r *InboxRepo) ListConsumedBefore(ctx context.Context, serviceName string, createdBefore time.Time, limit int) ([]int64, error)
- type OutboxDlqRepo
- func (r *OutboxDlqRepo) Delete(ctx context.Context, id int64) error
- func (r *OutboxDlqRepo) DeleteWithOutboxSuccess(ctx context.Context, outbox *model.SysEventOutbox, ...) error
- func (r *OutboxDlqRepo) Fetch(ctx context.Context, serviceName string, size int, maxRetry int, now time.Time) ([]model.SysEventOutboxDlq, error)
- func (r *OutboxDlqRepo) Insert(ctx context.Context, row *model.SysEventOutboxDlq) error
- func (r *OutboxDlqRepo) ResetRetryCountInTimeRange(ctx context.Context, serviceName string, from time.Time, to time.Time) (int64, error)
- func (r *OutboxDlqRepo) Update(ctx context.Context, row *model.SysEventOutboxDlq) error
- type OutboxRepo
- func (r *OutboxRepo) FetchFetchedTimeout(ctx context.Context, serviceName string, timeoutBefore time.Time) ([]model.SysEventOutbox, error)
- func (r *OutboxRepo) FetchPending(ctx context.Context, serviceName string, size int) ([]model.SysEventOutbox, error)
- func (r *OutboxRepo) FindByIDs(ctx context.Context, ids []int64) ([]model.SysEventOutbox, error)
- func (r *OutboxRepo) Insert(ctx context.Context, row *model.SysEventOutbox) error
- func (r *OutboxRepo) ListSentSuccessBefore(ctx context.Context, serviceName string, sentBefore time.Time, limit int) ([]int64, error)
- func (r *OutboxRepo) MarkFetchedBatch(ctx context.Context, ids []int64, fetchTime time.Time) ([]int64, error)
- func (r *OutboxRepo) MarkPendingBatch(ctx context.Context, ids []int64, fetchTimeBefore time.Time) (int64, error)
- func (r *OutboxRepo) MarkSentFail(ctx context.Context, id int64) (bool, error)
- func (r *OutboxRepo) MarkSentSuccess(ctx context.Context, id int64, sentTime time.Time) (bool, error)
- func (r *OutboxRepo) MarkSentSuccessFromDlq(ctx context.Context, id int64, sentTime time.Time) (bool, error)
- func (r *OutboxRepo) RestorePendingBatch(ctx context.Context, ids []int64) error
- func (r *OutboxRepo) Update(ctx context.Context, row *model.SysEventOutbox) error
- func (r *OutboxRepo) UpdateBatch(ctx context.Context, rows []model.SysEventOutbox) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InboxDlqRepo ¶
type InboxDlqRepo struct {
orm.BaseRepository
}
InboxDlqRepo 收件箱死信仓储
func NewInboxDlqRepo ¶
func NewInboxDlqRepo(dbConn *gorm.DB) *InboxDlqRepo
NewInboxDlqRepo 创建收件箱死信仓储
func (*InboxDlqRepo) Delete ¶
func (r *InboxDlqRepo) Delete(ctx context.Context, id int64) error
Delete 硬删除收件箱死信记录
func (*InboxDlqRepo) Fetch ¶
func (r *InboxDlqRepo) Fetch(ctx context.Context, serviceName string, size int, now time.Time) ([]model.SysEventInboxDlq, error)
Fetch 获取已到重投时间的收件箱死信记录
func (*InboxDlqRepo) Insert ¶
func (r *InboxDlqRepo) Insert(ctx context.Context, row *model.SysEventInboxDlq) error
Insert 插入收件箱死信记录;同一服务下 eventId 已存在时保持原记录不变
type InboxRepo ¶
type InboxRepo struct {
orm.BaseRepository
}
InboxRepo 收件箱仓储
type OutboxDlqRepo ¶
type OutboxDlqRepo struct {
orm.BaseRepository
}
OutboxDlqRepo 发件箱死信仓储
func NewOutboxDlqRepo ¶
func NewOutboxDlqRepo(dbConn *gorm.DB) *OutboxDlqRepo
NewOutboxDlqRepo 创建发件箱死信仓储
func (*OutboxDlqRepo) Delete ¶
func (r *OutboxDlqRepo) Delete(ctx context.Context, id int64) error
Delete 硬删除死信记录
func (*OutboxDlqRepo) DeleteWithOutboxSuccess ¶
func (r *OutboxDlqRepo) DeleteWithOutboxSuccess( ctx context.Context, outbox *model.SysEventOutbox, dlq *model.SysEventOutboxDlq, sentTime time.Time, outboxRepo *OutboxRepo, ) error
DeleteWithOutboxSuccess 事务内更新发件箱成功并删除死信
func (*OutboxDlqRepo) Fetch ¶
func (r *OutboxDlqRepo) Fetch(ctx context.Context, serviceName string, size int, maxRetry int, now time.Time) ([]model.SysEventOutboxDlq, error)
Fetch 获取待重试死信(仅返回未达最大重试次数且已过退避窗口的记录)
func (*OutboxDlqRepo) Insert ¶
func (r *OutboxDlqRepo) Insert(ctx context.Context, row *model.SysEventOutboxDlq) error
Insert 插入死信记录
func (*OutboxDlqRepo) ResetRetryCountInTimeRange ¶
func (r *OutboxDlqRepo) ResetRetryCountInTimeRange( ctx context.Context, serviceName string, from time.Time, to time.Time, ) (int64, error)
ResetRetryCountInTimeRange 将指定创建时间范围内的死信重试计数清零(供人工恢复)
func (*OutboxDlqRepo) Update ¶
func (r *OutboxDlqRepo) Update(ctx context.Context, row *model.SysEventOutboxDlq) error
Update 全量更新死信记录
type OutboxRepo ¶
type OutboxRepo struct {
orm.BaseRepository
}
OutboxRepo 发件箱仓储
func (*OutboxRepo) FetchFetchedTimeout ¶
func (r *OutboxRepo) FetchFetchedTimeout(ctx context.Context, serviceName string, timeoutBefore time.Time) ([]model.SysEventOutbox, error)
FetchFetchedTimeout 获取停留在 FETCHED 状态超时的事件
func (*OutboxRepo) FetchPending ¶
func (r *OutboxRepo) FetchPending(ctx context.Context, serviceName string, size int) ([]model.SysEventOutbox, error)
FetchPending 获取待处理事件
func (*OutboxRepo) FindByIDs ¶
func (r *OutboxRepo) FindByIDs(ctx context.Context, ids []int64) ([]model.SysEventOutbox, error)
FindByIDs 按主键批量查询
func (*OutboxRepo) Insert ¶
func (r *OutboxRepo) Insert(ctx context.Context, row *model.SysEventOutbox) error
Insert 插入发件箱记录
func (*OutboxRepo) ListSentSuccessBefore ¶
func (r *OutboxRepo) ListSentSuccessBefore( ctx context.Context, serviceName string, sentBefore time.Time, limit int, ) ([]int64, error)
ListSentSuccessBefore 查询指定服务下发送成功且已过保留期的发件箱记录 ID
func (*OutboxRepo) MarkFetchedBatch ¶
func (r *OutboxRepo) MarkFetchedBatch(ctx context.Context, ids []int64, fetchTime time.Time) ([]int64, error)
MarkFetchedBatch 仅将仍为 PENDING 的记录批量标记为 FETCHED,返回实际更新成功的 ID
func (*OutboxRepo) MarkPendingBatch ¶
func (r *OutboxRepo) MarkPendingBatch(ctx context.Context, ids []int64, fetchTimeBefore time.Time) (int64, error)
MarkPendingBatch 仅将仍为 FETCHED 且已超时的记录批量恢复为 PENDING,返回实际更新行数
func (*OutboxRepo) MarkSentFail ¶
MarkSentFail 仅将仍为 FETCHED 的记录标记为发送失败,返回是否实际更新
func (*OutboxRepo) MarkSentSuccess ¶
func (r *OutboxRepo) MarkSentSuccess(ctx context.Context, id int64, sentTime time.Time) (bool, error)
MarkSentSuccess 仅将仍为 FETCHED 的记录标记为发送成功,返回是否实际更新
func (*OutboxRepo) MarkSentSuccessFromDlq ¶
func (r *OutboxRepo) MarkSentSuccessFromDlq(ctx context.Context, id int64, sentTime time.Time) (bool, error)
MarkSentSuccessFromDlq 将非发送成功状态的事件标记为发送成功,用于死信重投成功后的回写
func (*OutboxRepo) RestorePendingBatch ¶
func (r *OutboxRepo) RestorePendingBatch(ctx context.Context, ids []int64) error
RestorePendingBatch 将指定发件箱记录批量恢复为待处理状态(仅处理 FETCHED 记录)
func (*OutboxRepo) Update ¶
func (r *OutboxRepo) Update(ctx context.Context, row *model.SysEventOutbox) error
Update 全量更新发件箱记录
全列 upsert 会覆盖并发状态;状态迁移请使用 MarkFetchedBatch/MarkPendingBatch/MarkSentSuccess/MarkSentFail。
func (*OutboxRepo) UpdateBatch ¶
func (r *OutboxRepo) UpdateBatch(ctx context.Context, rows []model.SysEventOutbox) error
UpdateBatch 批量全量更新发件箱记录(按固定分片提交,避免单条 SQL 过大)
全列 upsert 会覆盖并发状态;状态迁移请使用 MarkFetchedBatch/MarkPendingBatch。