Created
June 11, 2018 16:42
-
-
Save adamw/3b585c043a7a55bfa22d9f7eaaf1cc0e 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
val connect: Task[Queue[Task]] = Task | |
.eval(logger.info("[queue-start] connecting")) | |
.flatMap(_ => connector.connect) | |
.map { q => | |
logger.info("[queue-start] connected") | |
q | |
} | |
def consumeQueue(queue: Queue[Task]): Task[Unit] = | |
Task | |
.eval(logger.info("[queue] receiving message")) | |
.flatMap(_ => queue.read()) | |
.flatMap(msg => inbox.put(Received(msg))) | |
.cancelable | |
.restartUntil(_ => false) | |
def releaseQueue(queue: Queue[Task]): Task[Unit] = | |
Task | |
.eval(logger.info("[queue-stop] closing")) | |
.flatMap(_ => queue.close()) | |
.map(_ => logger.info("[queue-stop] closed")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment