If flush fails due to a network issue, you are forced to create a new sender... meaning all the messages you have buffered to be flushed get lost.
There's no re-connection logic (automatic or manual) and there's no way to check if the connection is alive.
Actually maybe it's not even a good idea to connect on NewLineSender() init, as there may be substantial delay between initialization and flushing, causing the connection to timeout (or disconnect due to any network error) before flush is even called.
There are a few issues with the current approach:
Actually maybe it's not even a good idea to connect on NewLineSender() init, as there may be substantial delay between initialization and flushing, causing the connection to timeout (or disconnect due to any network error) before flush is even called.