22 lines
1016 B
Go
22 lines
1016 B
Go
package domain
|
|
|
|
import "context"
|
|
|
|
type Repository interface {
|
|
// ReservePlatform atomically guards both limits and increments one monthly counter document.
|
|
// A negative limit means unlimited. BYOK must never call this operation.
|
|
ReservePlatform(ctx context.Context, uid int64, monthKey, meter string, cost, totalLimit, meterLimit int) error
|
|
GetMonthlyCounter(ctx context.Context, uid int64, monthKey string) (*MonthlyCounter, error)
|
|
|
|
InsertEvent(ctx context.Context, e *Event) error
|
|
ListEvents(ctx context.Context, uid int64, monthKey, keyMode string, limit int) ([]*Event, error)
|
|
ListEventsAll(ctx context.Context, monthKey string, limit int) ([]*Event, error)
|
|
ListEventsRange(ctx context.Context, fromNano, toExclusiveNano int64) ([]*Event, error)
|
|
|
|
GetPrefs(ctx context.Context, uid int64) (*MemberPrefs, error)
|
|
SavePrefs(ctx context.Context, p *MemberPrefs) error
|
|
|
|
InsertPurchase(ctx context.Context, p *Purchase) error
|
|
ListPurchases(ctx context.Context, uid int64, limit int) ([]*Purchase, error)
|
|
}
|