3 ms·
Scala derail: You might have an unintentional happens-before relationship in that example: The deletePersons call will end up being in the flatMap of the putAll
by NickPollard 13y ago
Scala derail: You might have an unintentional happens-before relationship in that example: The deletePersons call will end up being in the flatMap of the putAll[Person] call, which means it wont be started until the putAll finishes, when by the looks of it you could do both at once (only the createPerson needs to happen first).
You might want to do something like this:
for {
createResult <- Graph.createPerson(person)
} yield {
val a = Search.putAll[Person](createResult \ "updated_nodes")
val b = Search.deletePersons(createResult \ "deleted_nodes")
for ( _ <- a; _ <- b ) yield Created(createResult \ "node")
}
(notice starting the computations outside of the second for-comprehension, then just waiting for them inside)
- saryant 13y agoGood catch. :) Our production code actually does handle the relationship correctly, I just wanted to simplify in my example.