mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
fix(ActionScheduler): enqueue same-hour actions in wheel and add scheduling debug logs
This commit is contained in:
@@ -74,6 +74,7 @@ class ActionScheduler : AgentRunningSubModule<Set<ScheduledActionData>, Void>()
|
|||||||
schedulerScope.launch {
|
schedulerScope.launch {
|
||||||
scheduledActionDataSet?.run {
|
scheduledActionDataSet?.run {
|
||||||
for (scheduledActionData in scheduledActionDataSet) {
|
for (scheduledActionData in scheduledActionDataSet) {
|
||||||
|
log.debug("New action to schedule: {}", scheduledActionData)
|
||||||
actionCapability.putAction(scheduledActionData)
|
actionCapability.putAction(scheduledActionData)
|
||||||
timeWheel.schedule(scheduledActionData)
|
timeWheel.schedule(scheduledActionData)
|
||||||
}
|
}
|
||||||
@@ -121,11 +122,17 @@ class ActionScheduler : AgentRunningSubModule<Set<ScheduledActionData>, Void>()
|
|||||||
logFailedStatus(actionData)
|
logFailedStatus(actionData)
|
||||||
return@checkThenExecute
|
return@checkThenExecute
|
||||||
}
|
}
|
||||||
|
log.debug("Action next execution time: {}", parseToZonedDateTime)
|
||||||
|
|
||||||
val hour = parseToZonedDateTime.hour
|
val hour = parseToZonedDateTime.hour
|
||||||
actionsGroupByHour[hour].add(actionData)
|
actionsGroupByHour[hour].add(actionData)
|
||||||
|
log.debug("Action scheduled at {}", hour)
|
||||||
|
|
||||||
if (it.hour == hour) {
|
if (it.hour == hour) {
|
||||||
|
val wheelOffset = parseToZonedDateTime.minute * 60 + parseToZonedDateTime.second
|
||||||
|
wheel[wheelOffset].add(actionData)
|
||||||
state.value = WheelState.ACTIVE
|
state.value = WheelState.ACTIVE
|
||||||
|
log.debug("Action scheduled at wheel offset {}", wheelOffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user