Skip to content

Commit 7def8d7

Browse files
committed
replace relay push throttler with a sequencer
only preventing concurrent updates, without rate limitation
1 parent 7f306a0 commit 7def8d7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

modules/relay/src/main/RelayPush.scala

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,25 @@ import chess.format.pgn.PgnStr
55

66
import lila.study.MultiPgn
77
import lila.base.LilaInvalid
8+
import lila.hub.AsyncActorSequencers
9+
import lila.common.config.Max
810

9-
final class RelayPush(sync: RelaySync, api: RelayApi, irc: lila.irc.IrcApi)(using ActorSystem, Executor):
11+
final class RelayPush(sync: RelaySync, api: RelayApi, irc: lila.irc.IrcApi)(using Executor, Scheduler):
1012

11-
private val throttler = lila.hub.EarlyMultiThrottler[RelayRoundId](logger)
13+
private val workQueue = AsyncActorSequencers[RelayRoundId](
14+
maxSize = Max(8),
15+
expiration = 1 minute,
16+
timeout = 10 seconds,
17+
name = "relay.push"
18+
)
1219

1320
type Result = Either[LilaInvalid, Int]
1421

1522
def apply(rt: RelayRound.WithTour, pgn: PgnStr): Fu[Result] =
1623
if rt.round.sync.hasUpstream
1724
then fuccess(Left(LilaInvalid("The relay has an upstream URL, and cannot be pushed to.")))
1825
else
19-
throttler.ask[Result](rt.round.id, 1.seconds):
26+
workQueue(rt.round.id):
2027
pushNow(rt, pgn)
2128

2229
private def pushNow(rt: RelayRound.WithTour, pgn: PgnStr): Fu[Result] =

0 commit comments

Comments
 (0)