Skip to content

Commit

Permalink
Fix bug causing every guild create to rebalance
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Sep 14, 2024
1 parent 4e4d3fa commit 9319aeb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import kotlin.time.TimeSource
import io.kubernetes.client.util.Config as KubeConfig

private val startup = TimeSource.Monotonic.markNow()
private var lastRebalanceCheck = TimeSource.Monotonic.markNow()

private class RebalanceArguments() : Arguments() {
val forceTo by optionalInt {
Expand Down Expand Up @@ -66,9 +67,11 @@ class RebalancerExtension(context: PluginContext) : MikBotModule(context) {
failIfNot(ready)
// Do not call listener when pod just started
// this is to prevent initial guild_creates to cause this
failIf(startup.elapsedNow() > 5.minutes)
failIf(startup.elapsedNow() < 5.minutes)
failIf(lastRebalanceCheck.elapsedNow() < 1.minutes)
}
action {
lastRebalanceCheck = TimeSource.Monotonic.markNow()
val (_, newTotalShards) = getGatewayInfo()
if (newTotalShards > Config.TOTAL_SHARDS) {
reBalance(newTotalShards)
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ coroutines = "1.8.1"
serialization = "1.7.1"
ktor = "2.3.11"
kord = "feature-user-apps-20240825.234248-3"
api = "3.36.1"
api = "3.36.2"
ksp = "2.0.0-1.0.22"
lavakord = "7.1.0"

Expand Down

0 comments on commit 9319aeb

Please sign in to comment.