- Event model + ToJSON - EventSink interface + ChannelEventSink (non-blocking Submit) - event_repo: batch INSERT ON CONFLICT DO NOTHING dedup - event_service: 7-type whitelist + 1KB props limit + ReceivedAt auto-fill - event_flusher: 100/1s batch + sync metric_recent_level_ups on level_up - metric_weekly + metric_upcoming workers (5min/15min with pg_try_advisory_lock) - partitioner: 7-day pre-create + 30-day cleanup (00:05 create / 00:30 cleanup) - 22 unit + integration tests (model/repo/service/sink/worker) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
20 lines
600 B
Go
20 lines
600 B
Go
package sink
|
||
|
||
import (
|
||
"context"
|
||
|
||
"github.com/topfans/backend/services/statisticService/model"
|
||
)
|
||
|
||
// EventSink 事件 sink 接口
|
||
// 本期实现: ChannelEventSink(推到 channel,由 event_flusher 消费)
|
||
// 未来扩展: KafkaEventSink / ClickHouseDualWriteSink / SamplingEventSink
|
||
type EventSink interface {
|
||
// Submit 提交单个事件;非阻塞,channel 满时返回 ErrChannelFull
|
||
Submit(ctx context.Context, e *model.Event) error
|
||
// SubmitBatch 批量提交;任一失败即停止
|
||
SubmitBatch(ctx context.Context, es []*model.Event) error
|
||
// Close 关闭 sink
|
||
Close() error
|
||
}
|