Created
December 17, 2018 17:10
-
-
Save kylemccollom/5b371e58dd3f0dfbfe33841b93ecd983 to your computer and use it in GitHub Desktop.
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
batch match { | |
// this is the first of the batch | |
case Nil => | |
// add this payment to the batch | |
context.become(ready(accnKey, accn, replyTo, Seq(payment))) | |
// remind myself in 1 second from now to flush the batch | |
context.system.scheduler.scheduleOnce(1.second, self, Flush) | |
// this is the last that can fit inside the batch | |
case _ if batch.size == MaxTxnLength - 1 => | |
// transact the batch right now | |
transmit(payment +: batch) | |
// clear the batch | |
context.become(ready(accnKey, accn.withIncSeq, replyTo)) | |
// it’s not the first payment, nor the last | |
case _ => | |
// add this payment to the batch | |
context.become(ready(accnKey, accn, replyTo, payment +: batch)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment