Skip to content

Instantly share code, notes, and snippets.

@ghostdogpr
Created July 21, 2019 08:52
Show Gist options
  • Save ghostdogpr/c2b1c2d9f673e076c44363c1cdd20149 to your computer and use it in GitHub Desktop.
Save ghostdogpr/c2b1c2d9f673e076c44363c1cdd20149 to your computer and use it in GitHub Desktop.
Stream.fromEffect {
IO.effectAsync[Any, Throwable, List[Message]] { cb =>
client
.receiveMessage(ReceiveMessageRequest.builder.queueUrl(queueUrl).maxNumberOfMessages(10).build)
.handle[Unit]((result, err) => {
err match {
case null => cb(IO.succeed(result.messages.asScala.toList))
case ex => cb(IO.fail(ex))
}
})
()
}
}.forever
.flatMap[Any, Throwable, Message](Stream.fromIterable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment