Skip to content

Instantly share code, notes, and snippets.

@kastoestoramadus
Last active June 28, 2017 07:56
Show Gist options
  • Save kastoestoramadus/fe3eed760997da32cdcf to your computer and use it in GitHub Desktop.
Save kastoestoramadus/fe3eed760997da32cdcf to your computer and use it in GitHub Desktop.
// generate cyclic sending mail wiht rotation on chosen data
private def generateMailsSending(sentmails: Meter): Cancellable = {
import sys.process._
val getNextHeaderSet: () => ClientHeaders = {
def b(): Stream[ClientHeaders] = headers.toStream #::: b
var cyclicIterator: Stream[ClientHeaders] = b()
() => {
val tail = cyclicIterator.tail
val result = tail.head
cyclicIterator = tail
result
}
}
// requires sendmail and unix os host
context.system.scheduler.schedule(Config.MAILS_DURATION, Config.MAILS_DURATION) {
"echo anything" #| s"sendmail ${getNextHeaderSet().msisdn}@[$BASE_IP]" !;
sentmails.mark()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment