mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 00:14:00 +00:00
feat: wire persistent queue backend into API
This commit is contained in:
@@ -91,6 +91,21 @@ type queueTicketRecord struct {
|
||||
Revision uint64 `json:"revision"`
|
||||
}
|
||||
|
||||
type PostgresQueue struct{ DB *sql.DB }
|
||||
|
||||
func (q PostgresQueue) Create(ctx context.Context, playerID, ticketID, idempotencyKey string, spec domain.QueueSpec, now time.Time) (domain.QueueTicket, error) {
|
||||
return CreateQueueTicket(ctx, q.DB, ticketID, playerID, idempotencyKey, spec, now)
|
||||
}
|
||||
func (q PostgresQueue) Heartbeat(ctx context.Context, playerID, ticketID, idempotencyKey string, revision uint64, now time.Time) (domain.QueueTicket, error) {
|
||||
return HeartbeatQueueTicket(ctx, q.DB, playerID, ticketID, idempotencyKey, revision, now)
|
||||
}
|
||||
func (q PostgresQueue) Cancel(ctx context.Context, playerID, ticketID, idempotencyKey string, revision uint64, now time.Time) (domain.QueueTicket, error) {
|
||||
return CancelQueueTicket(ctx, q.DB, playerID, ticketID, idempotencyKey, revision, now)
|
||||
}
|
||||
func (q PostgresQueue) Get(ctx context.Context, playerID, ticketID string, now time.Time) (domain.QueueTicket, error) {
|
||||
return GetQueueTicket(ctx, q.DB, playerID, ticketID, now)
|
||||
}
|
||||
|
||||
func GetQueueTicket(ctx context.Context, db *sql.DB, playerID, ticketID string, now time.Time) (domain.QueueTicket, error) {
|
||||
if db == nil || playerID == "" || ticketID == "" || now.IsZero() {
|
||||
return domain.QueueTicket{}, fmt.Errorf("invalid queue recovery arguments")
|
||||
|
||||
Reference in New Issue
Block a user