taer
06/16/2023, 4:47 PMmap
calls, but that's ugly. flowOn smells like it's the right thing, but it doesn't get "each message".
I tried this:
val mdcFlowOfMessages = messageFlow.transform {
withContext(MDCContext(mapOf("sqs-message-id" to it.messageId()))) {
emit(it)
}
}
and it failed like it should - Flow invariant is violated - because I'm emmitting from a different context. Any suggestions on ways to accomplish this?
For now, my 2 different map
calls are extracted to a function that does a withContext
at the start. I know I could probably use a channel flow for the above code, but that smells heavy handed.