Files
ProxyPool/internal/store/store.go
2026-01-31 22:53:12 +08:00

56 lines
1.7 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"
"proxyrotator/internal/model"
)
// ProxyStore 代理存储接口
type ProxyStore interface {
// UpsertMany 批量导入代理upsert + 去重统计)
UpsertMany(ctx context.Context, proxies []model.Proxy) (imported, duplicated int, err error)
// List 查询代理列表
List(ctx context.Context, q model.ProxyQuery) ([]model.Proxy, error)
// ListPaginated 分页查询代理列表,返回数据和总数
ListPaginated(ctx context.Context, q model.ProxyListQuery) ([]model.Proxy, int, error)
// GetByID 根据 ID 获取代理
GetByID(ctx context.Context, id string) (*model.Proxy, error)
// UpdateHealth 更新代理健康度
UpdateHealth(ctx context.Context, proxyID string, patch model.HealthPatch) error
// Update 更新代理字段
Update(ctx context.Context, id string, patch model.ProxyPatch) error
// Delete 删除单个代理
Delete(ctx context.Context, id string) error
// DeleteMany 批量删除代理
DeleteMany(ctx context.Context, req model.BulkDeleteRequest) (int64, error)
// GetStats 获取代理统计信息
GetStats(ctx context.Context) (*model.ProxyStats, error)
// NextIndex RR 原子游标:返回 [0, modulo) 的索引
NextIndex(ctx context.Context, key string, modulo int) (int, error)
// CreateLease 创建租约
CreateLease(ctx context.Context, lease model.Lease) error
// GetLease 获取租约
GetLease(ctx context.Context, leaseID string) (*model.Lease, error)
// DeleteExpiredLeases 删除过期租约
DeleteExpiredLeases(ctx context.Context) (int64, error)
// InsertTestLog 插入测试日志
InsertTestLog(ctx context.Context, r model.TestResult, site string) error
// Close 关闭连接
Close() error
}