owpengram-server/internal/store/update_event.go
2026-06-04 01:37:39 +08:00

26 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package store
import (
"context"
"telesrv/internal/domain"
)
// UpdateEventStore 持久化 user 维度的增量事件。
type UpdateEventStore interface {
Append(ctx context.Context, userID int64, event domain.UpdateEvent) error
ListAfter(ctx context.Context, userID int64, pts, limit int) ([]domain.UpdateEvent, error)
Current(ctx context.Context, userID int64) (int, error)
// MaxContiguousPts 返回从 1 起无空洞的最大已提交 pts。
// 并发发送在途时pts 已分配未提交)会暂时小于 Current最大已提交空洞提交/补洞后回升。
// getState/getDifference 据此只暴露连续 pts避免客户端跳过在途空洞而丢消息。
MaxContiguousPts(ctx context.Context, userID int64) (int, error)
// AdvanceContiguousPts 推进并返回账号级连续 pts 水位。实现应在写事件的同一事务内调用。
AdvanceContiguousPts(ctx context.Context, userID int64) (int, error)
}
// EventCursor 精确定位单条账号事件,用于 outbox worker 批量加载已 claim 事件。
type EventCursor struct {
UserID int64
Pts int
}