mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 18:13:42 +00:00
fix(multiplayer): avoid quota double charge on recovery
This commit is contained in:
@@ -138,14 +138,9 @@ func (s Service) RecordProviderAllocation(ctx context.Context, result agones.All
|
||||
if s.Durable == nil || result.Allocation.State != domain.ServerAllocated || result.Endpoint == "" {
|
||||
return domain.Allocation{}, domain.ErrAllocationInput
|
||||
}
|
||||
if s.Quota != nil {
|
||||
if err := s.Quota.Consume(ctx, result.Allocation.Region, now); err != nil {
|
||||
if s.Metrics != nil {
|
||||
s.Metrics.ObserveDenied(result.Allocation.Region)
|
||||
}
|
||||
return domain.Allocation{}, err
|
||||
}
|
||||
}
|
||||
// Quota is consumed by Allocate before a fresh provider request. This
|
||||
// method only reconciles an already-issued provider result after an
|
||||
// ambiguous write, so consuming here would charge one allocation twice.
|
||||
allocation, err := s.Durable.RecordProviderAllocation(ctx, result.Allocation, now)
|
||||
if s.Metrics != nil {
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user