diff --git a/http_integration_test.go b/http_integration_test.go index 17b0a01..246e6cb 100644 --- a/http_integration_test.go +++ b/http_integration_test.go @@ -87,3 +87,38 @@ func (suite *integrationTestSuite) TestE2ESuccessfulHttpBasicAuthWithTlsProxy() return reflect.DeepEqual(expected, data) }, eventualDataTimeout, 100*time.Millisecond) } + +func (suite *integrationTestSuite) TestServerSideError() { + if testing.Short() { + suite.T().Skip("skipping integration test") + } + + ctx := context.Background() + + var ( + sender qdb.LineSender + err error + ) + + questdbC, err := setupQuestDB(ctx, noAuth) + assert.NoError(suite.T(), err) + + sender, err = qdb.NewLineSender(ctx, qdb.WithHttp(), qdb.WithAddress(questdbC.httpAddress)) + assert.NoError(suite.T(), err) + + err = sender.Table(testTable).Int64Column("long_col", 42).AtNow(ctx) + assert.NoError(suite.T(), err) + err = sender.Flush(ctx) + assert.NoError(suite.T(), err) + + // Now, use wrong type for the long_col. + err = sender.Table(testTable).StringColumn("long_col", "42").AtNow(ctx) + assert.NoError(suite.T(), err) + err = sender.Flush(ctx) + assert.Error(suite.T(), err) + assert.ErrorContains(suite.T(), err, "my_test_table, column: long_col; cast error from protocol type: STRING to column type") + assert.ErrorContains(suite.T(), err, "line: 1") + + sender.Close(ctx) + questdbC.Stop(ctx) +} diff --git a/http_sender_test.go b/http_sender_test.go index 68fa37a..e404ede 100644 --- a/http_sender_test.go +++ b/http_sender_test.go @@ -143,6 +143,14 @@ func TestHttpPathologicalCasesFromConf(t *testing.T) { } } +func TestErrorWhenSenderTypeIsNotSpecified(t *testing.T) { + ctx := context.Background() + + _, err := qdb.NewLineSender(ctx) + assert.Error(t, err) + assert.ErrorContains(t, err, "sender type is not specified: use WithHttp or WithTcp") +} + func TestHttpErrorWhenMaxBufferSizeIsReached(t *testing.T) { ctx := context.Background() diff --git a/sender.go b/sender.go index 24ecbfe..2a73431 100644 --- a/sender.go +++ b/sender.go @@ -407,7 +407,7 @@ func WithAutoFlushInterval(interval time.Duration) LineSenderOption { // http(s) and tcp(s): // ------------------- // addr: hostname/port of QuestDB endpoint -// init_buf_size: initial growable ILP buffer size in bytes (defaults to 64KiB) +// init_buf_size: initial growable ILP buffer size in bytes (defaults to 128KiB) // tls_verify: determines if TLS certificates should be validated (defaults to "on", can be set to "unsafe_off") // // http(s)-only @@ -420,13 +420,12 @@ func WithAutoFlushInterval(interval time.Duration) LineSenderOption { // request_min_throughput: bytes per second, used to calculate each request's timeout (defaults to 100KiB/s) // request_timeout: minimum request timeout in milliseconds (defaults to 10 seconds) // retry_timeout: cumulative maximum millisecond duration spent in retries (defaults to 10 seconds) -// max_buf_size: buffer growth limit in bytes. client errors if breached (default is 100MiB) +// max_buf_size: buffer growth limit in bytes. Client errors if breached (default is 100MiB) // // tcp(s)-only // ----------- // username: KID (key ID) for ECDSA authentication // token: Secret K (D) for ECDSA authentication - func LineSenderFromConf(ctx context.Context, conf string) (LineSender, error) { c, err := confFromStr(conf) if err != nil {