mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-13 18:32:03 +00:00
feat(multiplayer): persist live reconnect abandonments
This commit is contained in:
@@ -25,6 +25,7 @@ func main() {
|
||||
stalledAllocationDeadline := flag.Duration("stalled-allocation-deadline", 2*time.Minute, "reclaim a match stuck in ALLOCATING/PROCESS_READY/ASSIGNMENT_READY (server crashed or was reclaimed before registering) after this long, requeuing every participant without penalty")
|
||||
stalledAllocationBatch := flag.Int("stalled-allocation-batch", 100, "maximum stalled matches reclaimed per pass")
|
||||
initialConnectBatch := flag.Int("initial-connect-batch", 100, "maximum pre-live matches evaluated per pass")
|
||||
liveAbandonmentBatch := flag.Int("live-abandonment-batch", 100, "maximum live ranked matches evaluated for expired reconnect leases per pass")
|
||||
flag.Parse()
|
||||
if *dsn == "" {
|
||||
fatalf("--dsn or COSMIC_CLASH_POSTGRES_DSN is required")
|
||||
@@ -35,8 +36,8 @@ func main() {
|
||||
if *stalledAllocationDeadline <= 0 || *stalledAllocationBatch < 1 || *stalledAllocationBatch > 1000 {
|
||||
fatalf("invalid stalled-allocation deadline or batch")
|
||||
}
|
||||
if *initialConnectBatch < 1 || *initialConnectBatch > 1000 {
|
||||
fatalf("invalid initial-connect batch")
|
||||
if *initialConnectBatch < 1 || *initialConnectBatch > 1000 || *liveAbandonmentBatch < 1 || *liveAbandonmentBatch > 1000 {
|
||||
fatalf("invalid initial-connect or live-abandonment batch")
|
||||
}
|
||||
db, err := sql.Open("pgx", *dsn)
|
||||
if err != nil {
|
||||
@@ -77,6 +78,13 @@ func main() {
|
||||
if reconciled > 0 {
|
||||
log.Printf("reconciled %d initial-connect outcomes", reconciled)
|
||||
}
|
||||
abandoned, err := store.ReconcileLiveAbandonments(ctx, db, now, *liveAbandonmentBatch)
|
||||
if err != nil {
|
||||
fatalf("live-abandonment maintenance: %v", err)
|
||||
}
|
||||
if abandoned > 0 {
|
||||
log.Printf("recorded expired reconnect leases in %d live matches", abandoned)
|
||||
}
|
||||
}
|
||||
|
||||
runGeneral(time.Now().UTC())
|
||||
|
||||
Reference in New Issue
Block a user