Skip to content

Commit

Permalink
Minor changes based on review
Browse files Browse the repository at this point in the history
changelog_begin
changelog_end
  • Loading branch information
nmarton-da committed Jul 13, 2021
1 parent 27ec6e0 commit 5a7cd1a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ object HaCoordinator {
mainLockChecker <- go[PollingChecker](
new PollingChecker(
periodMillis = haConfig.mainLockCheckerPeriodMillis,
check = acquireMainLock(mainConnection),
checkBody = acquireMainLock(mainConnection),
killSwitch =
handle.killSwitch, // meaning: this PollingChecker will shut down the main preemptableSequence
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import java.util.concurrent.atomic.AtomicReference
import akka.stream.KillSwitch
import com.daml.logging.{ContextualizedLogger, LoggingContext}

/** A KillSwitch which captures it's usage
* - Shutdown always wins
* - From aborts, the last abort wins
* - With setDelegate() we can set a delegate KillSwitch, which to usage will be replayed
* - Captured state is available with state
/** This KillSwitch captures it's usage in it's internal state, which can be queried.
* Captured state is available with the 'state' method.
*
* Rules of state transitions:
* - Shutdown is always the final state
* - From multiple aborts, the last abort wins
*
* With setDelegate() we can set a delegate KillSwitch, which to usage will be replayed
*/
class KillSwitchCaptor(implicit loggingContext: LoggingContext) extends KillSwitch {
import KillSwitchCaptor._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import scala.util.{Failure, Success, Try}
* - It is also an AutoCloseable to release internal resources
*
* @param periodMillis period of the checking, between each scheduled checks there will be so much delay
* @param check the check function, Exception signals failed check
* @param checkBody the check function, Exception signals failed check
* @param killSwitch to abort if a check fails
*/
class PollingChecker(
periodMillis: Long,
check: => Unit,
checkBody: => Unit,
killSwitch: KillSwitch,
)(implicit loggingContext: LoggingContext)
extends AutoCloseable {
Expand All @@ -49,7 +49,7 @@ class PollingChecker(
// (the peak scenario) which should be enough, and which can leave this code very simple.
def check(): Unit = synchronized {
logger.debug(s"Checking...")
Try(check) match {
Try(checkBody) match {
case Success(_) =>
logger.debug(s"Check successful.")

Expand Down

0 comments on commit 5a7cd1a

Please sign in to comment.