I am querying InfluxDB from my Golang lambda function. While creating the client I am adding the timeout as follows:
influxClientOptions := influxdb2.DefaultOptions()
influxClientOptions.SetHTTPClient(retryClient.StandardClient())
influxClientOptions.SetHTTPRequestTimeout(1) //Setting the timeout as 1 second here
client := influxdb2.NewClientWithOptions(host, token, influxClientOptions)
Then I am querying the InfluxDB with a query like:
queryAPI := client.QueryAPI("my_organization")
query := "from(bucket: ....." // Some query that takes more than 1 second
result, err := queryAPI.Query(context.Background(), query)
if err != nil {
logging.FromContext(ctx).WithError(err).Error("influx query failed with error: ", err)
return r, "Influx query failed"
}
if result.Err() != nil { // error raised during flux query response parsing
logging.FromContext(ctx).WithError(result.Err()).Errorf("influx query error while parsing result: %s", result.Err())
return r, "Influx query failed"
}
This query takes more than 1 second, but I am not getting any timeout error after 1 second. My query is getting completed successfully instead of throwing error since the timeout set is 1 second.
What am I doing wrong here?
Expectation: I am expecting the query to stop the query and return an error after 1 second.