feat(multiplayer): run leased allocator worker

This commit is contained in:
Josh Creek
2026-09-01 10:38:45 +01:00
parent 6f7d61eafb
commit 55c46f56ec
6 changed files with 255 additions and 6 deletions
+34
View File
@@ -0,0 +1,34 @@
package store
import (
"context"
"database/sql"
"time"
"github.com/cosmic-clash/cosmic-clash/server/domain"
)
// AllocatingMatchClaims adapts the PostgreSQL lease boundary for allocator
// workers without making the allocator package depend on the store package.
type AllocatingMatchClaims struct {
DB *sql.DB
Transport string
}
func (s AllocatingMatchClaims) ClaimAllocatingMatch(ctx context.Context, now time.Time) (domain.AllocationRequest, bool, error) {
item, found, err := ClaimAllocatingMatch(ctx, s.DB, s.Transport, now)
return item.Request, found, err
}
func (s AllocatingMatchClaims) BindAllocatedMatch(ctx context.Context, allocation domain.Allocation) error {
return BindAllocatedMatch(ctx, s.DB, allocation)
}
// AllocationRegistry adapts provider-allocation reconciliation for allocator
// workers. A successful provider response is not publishable until this store
// boundary records the same compatibility tuple and GameServer identity.
type AllocationRegistry struct{ DB *sql.DB }
func (s AllocationRegistry) RecordProviderAllocation(ctx context.Context, allocation domain.Allocation, now time.Time) (domain.Allocation, error) {
return RecordProviderAllocation(ctx, s.DB, allocation, now)
}