Files
2026-10-25 17:10:40 +03:00

27 lines
1.4 KiB
Ruby

# Matchmaking configuration. All values can be overridden via environment variables.
mm = Rails.application.config.x.matchmaking = ActiveSupport::OrderedOptions.new
mm.game_server_url = ENV.fetch("GAME_SERVER_URL", "ws://localhost:8080")
# Players' initial rating lives in the DB (users.rating, default 100),
# so no default rating is configured here.
# How long a found match (and its game token) stays valid, in seconds.
mm.match_ttl = ENV.fetch("MATCHMAKING_MATCH_TTL", 120).to_i
mm.token_ttl = ENV.fetch("MATCHMAKING_TOKEN_TTL", 120).to_i
# How long a player waits in the queue before a timeout, in seconds.
mm.queue_ttl = ENV.fetch("MATCHMAKING_QUEUE_TTL", 60).to_i
# How long a found (but not yet finalized) pair is kept in the "pending"
# state before the players are put back into the queue, in seconds.
mm.pending_ttl = ENV.fetch("MATCHMAKING_PENDING_TTL", 15).to_i
# Rating tolerance: players within `base_range` are matched immediately;
# the tolerance grows by `range_per_second` of waiting up to `max_range`.
mm.base_range = ENV.fetch("MATCHMAKING_BASE_RANGE", 100).to_i
mm.range_per_second = ENV.fetch("MATCHMAKING_RANGE_PER_SECOND", 50).to_i
mm.max_range = ENV.fetch("MATCHMAKING_MAX_RANGE", 1000).to_i
# How often the background sweep job re-checks the queue, in seconds.
mm.sweep_interval = ENV.fetch("MATCHMAKING_SWEEP_INTERVAL", 2).to_i