Created
March 26, 2018 00:28
-
-
Save afsalthaj/e35a32433383850befa314e5f7ff749a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import scala.compat.java8.FutureConverters.toScala | |
// eh.send returns a completable future in Java. we convert it to Scala future | |
// and throttle sending the data to eventhub in azure nicely and easily! | |
private def sendDataInFutureControlled: Seq[EventData] => EventHubClient => Future[Iterator[Void]] = | |
seq => eh => { | |
// We throttle it and send in sequence to make sure that we are not overloading eventhub | |
Future.sequence(seq.grouped(3).map(s => toScala[Void](eh.send(s.asJava)))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment