jkbbwr
04/11/2018, 11:45 AMelizarov
04/11/2018, 1:25 PMelizarov
04/12/2018, 9:59 AMjkbbwr
04/12/2018, 12:19 PMelizarov
04/12/2018, 5:02 PMactor { ... }
builder for pull if I correctly understand what you mean.jkbbwr
04/13/2018, 2:25 AMfun acceptor() = actor<Message> {
var ballot = -1
var server = -1
var acceptedBallot: Int? = null
var acceptedValue: Any? = null
fun handleProposal(message: Message.Propose) {
// Did I promise to ignore this
when {
message.ballot < ballot -> {
// Yea I promised to ignore this guy
message.reply(null)
return
}
message.ballot > ballot -> {
// Yes they are, repromise to this person
ballot = message.ballot
message.reply(Message.Promise(
message.ballot,
acceptedBallot,
acceptedValue
))
return
}
message.ballot == ballot -> {
TODO()
}
}
}
fun handleFinalise(message: Message.Finalise) {
// Did we promise to ignore this
when {
message.ballot < ballot -> {
// Yea we are well past this
message.reply(null)
}
message.ballot >= ballot -> {
acceptedBallot = message.ballot
acceptedValue = message.value
message.reply(Message.Commit(
message.ballot,
message.value
))
}
else -> TODO("pid compare.")
}
}
for (it in channel) {
when(it) {
is Message.Propose -> handleProposal(it)
is Message.Finalise -> handleFinalise(it)
}
}
}
Is what I am currently having to do