questdb / go-questdb-client

Golang client for QuestDB's Influx Line Protocol
Apache License 2.0
47 stars 9 forks source link

Does not reconnect on disconnection? #9

Closed trythrow closed 8 months ago

trythrow commented 1 year ago

Hello and thank you for all the great efforts put into the questdb project. I have been using the client for a few days now and it came to my attention that the client does not seem to reconnect on TCP disconnections. The way it works now is that you will need to take the following steps

  1. Establish a connection
  2. Call LineSender.Table... then LineSender.At
  3. Flush lines
  4. Close connection

The above will need to be repeated every time there is a need to send the data to questdb. This is most likely by design and is intended to work this way. Though there is an overhead for establishing a connection every time one wants to send data or reconnect during a flush error.

Would it be desirable to have the client auto-connect and maintain the connection with the server?

puzpuzpuz commented 1 year ago

Sorry for the late reply.

Would it be desirable to have the client auto-connect and maintain the connection with the server?

In general, establishing a connection on each row and even on a batch of rows is expensive, so it should be avoided. Instead, it's better to create a sender or multiple senders somewhere at the start of your application and reuse them later. Just keep in mind that LineSender is not thread-safe, so you should synchronize access to it.

puzpuzpuz commented 8 months ago

v3 shipped HTTP sender which has the automatic retry logic.