mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 08:23:45 +00:00
fix(multiplayer): recover ambiguous agones allocations
This commit is contained in:
@@ -14,6 +14,10 @@ type Provider interface {
|
||||
Allocate(context.Context, domain.AllocationRequest, map[string]string, time.Time) (agones.AllocatedServer, error)
|
||||
}
|
||||
|
||||
type ProviderRecoverer interface {
|
||||
RecoverAllocation(context.Context, domain.AllocationRequest, time.Time) (agones.AllocatedServer, bool, error)
|
||||
}
|
||||
|
||||
type Durable interface {
|
||||
RecordProviderAllocation(context.Context, domain.Allocation, time.Time) (domain.Allocation, error)
|
||||
}
|
||||
@@ -84,6 +88,13 @@ func (s Service) Allocate(ctx context.Context, request domain.AllocationRequest,
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s Service) RecordProviderAllocation(ctx context.Context, result agones.AllocatedServer, now time.Time) (domain.Allocation, error) {
|
||||
if s.Durable == nil || result.Allocation.State != domain.ServerAllocated || result.Endpoint == "" {
|
||||
return domain.Allocation{}, domain.ErrAllocationInput
|
||||
}
|
||||
return s.Durable.RecordProviderAllocation(ctx, result.Allocation, now)
|
||||
}
|
||||
|
||||
var errNotConfigured = &configurationError{}
|
||||
|
||||
type configurationError struct{}
|
||||
|
||||
Reference in New Issue
Block a user