How to efficiently separate logger from app?

I’d like to ask for a recommendatation as I haven’t had such a task yet.

I stream data from a server, log them to a file as well as do some calculation on the fly (both written in golang). The problem is that whenever there’s a bug in the calculations, the program panics and the streaming/logging is stopped as well. How would I efficiently separeate streaming and calculation apps in a way that calculation app is using the streamed data? One solution coming to my mind is with tail command in Linux, but this is already using some external solution, probably with much overhead. Any suggestions very much appreciated :pray:t2:

Write a channel pipeline. In the goroutine that does the calculation, defer a panic recovery. If a panic occurs, log the error and continue reading from the channel so that the streaming can continue.

1 Like

Thanks for a suggestion, will look into it and I think will be able to implement it. If, perhaps, there’s a simple example, would be appreciated… thanks!!

I just want to thanks to @mje for leading me to the right direction and add this article which helped me a lot in solveing my problem.Thanks!!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.