This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./journalioMigration oldLogsRoot newLogsRoot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def startService(in: In)(implicit progress: MultiPhasedProgress) { | |
progress.inPhase("Preparing data") { | |
prepareData(in) | |
(...) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def countPhases(config: Config) = { | |
val retrievePhases = 2 | |
val validatingPhases = validationService.predictPhases(config) | |
val generatingPhases = 1 | |
val marshallingPhases = 1 | |
retrievePhases + validatingPhases + generatingPhases + marshallingPhases | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val chain = | |
Phase("Preparation") { in: Int => PreparedData(in) } :: | |
Phase("Validation") { data: PreparedData => ValidatedData(data) } :: | |
Phase("Execution") { data: ValidatedData => Result(data) } :: | |
NilChain() | |
val progress = new MultiPhasedProgress(chain) | |
val result = progress.run(123) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Phase[-In, +Out](private[phase] val name: String, | |
private[phase] val process: In => Out) | |
object Phase { | |
def apply[In, Out](name: String) | |
(process: In => Out) = new Phase(name, process) | |
} | |
trait PhasesChain[-In, +Out] extends ChainTransformation[In, Out] { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait ValidatingPhasesChain[-In, +OutF, +OutS] extends PhasesChain[In, Validation[OutF, OutS]] { | |
def ::[NIn, NOutF >: OutF](prev: ValidatingPhase[NIn, NOutF, In]): ValidatingPhasesChain[NIn, NOutF, OutS] = | |
new ChainedValidatingPhase(prev, this) | |
protected def processIfSuccessOrMoveProgress[MidF, MidS, OutSS](progress: MultiPhasedProgress) | |
(next: ValidatingPhasesChain[MidS, MidF, OutSS]) | |
(mid: Validation[MidF, MidS]) = mid match { | |
case Success(s) => | |
next.processWithProgress(progress)(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private def notifyAboutStatus() { | |
progressHoldingActor ! progressState.status | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ scala CastingTest | |
value: 123 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def casted: T = value match { | |
case t: T => t | |
case _ => throw new ClassCastException(s"Cannot cast $value to expected type") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ scalac CastingTest.scala | |
CastingTest.scala:5: warning: abstract type pattern T is unchecked since it is eliminated by erasure | |
case t: T => t | |
^ | |
one warning found |