@@ -401,17 +401,30 @@ class line_sender_buffer
401
401
{
402
402
}
403
403
404
+ line_sender_buffer (
405
+ size_t init_buf_size,
406
+ size_t max_name_len,
407
+ line_protocol_version version) noexcept
408
+ : _impl{nullptr }
409
+ , _init_buf_size{init_buf_size}
410
+ , _max_name_len{max_name_len}
411
+ , _line_protocol_version{version}
412
+ {
413
+ }
414
+
404
415
line_sender_buffer (const line_sender_buffer& other) noexcept
405
416
: _impl{::line_sender_buffer_clone (other._impl )}
406
417
, _init_buf_size{other._init_buf_size }
407
418
, _max_name_len{other._max_name_len }
419
+ , _line_protocol_version{other._line_protocol_version }
408
420
{
409
421
}
410
422
411
423
line_sender_buffer (line_sender_buffer&& other) noexcept
412
424
: _impl{other._impl }
413
425
, _init_buf_size{other._init_buf_size }
414
426
, _max_name_len{other._max_name_len }
427
+ , _line_protocol_version{other._line_protocol_version }
415
428
{
416
429
other._impl = nullptr ;
417
430
}
@@ -427,6 +440,7 @@ class line_sender_buffer
427
440
_impl = nullptr ;
428
441
_init_buf_size = other._init_buf_size ;
429
442
_max_name_len = other._max_name_len ;
443
+ _line_protocol_version = other._line_protocol_version ;
430
444
}
431
445
return *this ;
432
446
}
@@ -439,11 +453,32 @@ class line_sender_buffer
439
453
_impl = other._impl ;
440
454
_init_buf_size = other._init_buf_size ;
441
455
_max_name_len = other._max_name_len ;
456
+ _line_protocol_version = other._line_protocol_version ;
442
457
other._impl = nullptr ;
443
458
}
444
459
return *this ;
445
460
}
446
461
462
+ /* *
463
+ * Sets the Line Protocol version for line_sender_buffer.
464
+ *
465
+ * The buffer defaults is line_protocol_version_2 which uses
466
+ * binary format f64 serialization and support array data type. Call this to
467
+ * switch to version 1 (text format f64) when connecting to servers that
468
+ * don't support line_protocol_version_2(under 8.3.2).
469
+ *
470
+ * Must be called before adding any data to the buffer. Protocol version
471
+ * cannot be changed after the buffer contains data.
472
+ */
473
+ line_sender_buffer& set_line_protocol_version (line_protocol_version v)
474
+ {
475
+ may_init ();
476
+ line_sender_error::wrapped_call (
477
+ ::line_sender_buffer_set_line_protocol_version, _impl, v);
478
+ _line_protocol_version = v;
479
+ return *this ;
480
+ }
481
+
447
482
/* *
448
483
* Pre-allocate to ensure the buffer has enough capacity for at least
449
484
* the specified additional byte count. This may be rounded up.
@@ -803,12 +838,17 @@ class line_sender_buffer
803
838
{
804
839
_impl = ::line_sender_buffer_with_max_name_len (_max_name_len);
805
840
::line_sender_buffer_reserve (_impl, _init_buf_size);
841
+ line_sender_error::wrapped_call (
842
+ line_sender_buffer_set_line_protocol_version,
843
+ _impl,
844
+ _line_protocol_version);
806
845
}
807
846
}
808
847
809
848
::line_sender_buffer* _impl;
810
849
size_t _init_buf_size;
811
850
size_t _max_name_len;
851
+ line_protocol_version _line_protocol_version{::line_protocol_version_2};
812
852
813
853
friend class line_sender ;
814
854
};
@@ -868,13 +908,24 @@ class opts
868
908
* @param[in] protocol The protocol to use.
869
909
* @param[in] host The QuestDB database host.
870
910
* @param[in] port The QuestDB tcp or http port.
911
+ * @param[in] disable_line_protocol_validation disable line protocol version
912
+ * validation.
871
913
*/
872
- opts (protocol protocol, utf8_view host, uint16_t port) noexcept
914
+ opts (
915
+ protocol protocol,
916
+ utf8_view host,
917
+ uint16_t port,
918
+ bool disable_line_protocol_validation = false ) noexcept
873
919
: _impl{::line_sender_opts_new (
874
920
static_cast <::line_sender_protocol>(protocol), host._impl , port)}
875
921
{
876
922
line_sender_error::wrapped_call (
877
923
::line_sender_opts_user_agent, _impl, _user_agent::name ());
924
+ if (disable_line_protocol_validation)
925
+ {
926
+ line_sender_error::wrapped_call (
927
+ ::line_sender_opts_disable_line_protocol_validation, _impl);
928
+ }
878
929
}
879
930
880
931
/* *
@@ -883,15 +934,25 @@ class opts
883
934
* @param[in] protocol The protocol to use.
884
935
* @param[in] host The QuestDB database host.
885
936
* @param[in] port The QuestDB tcp or http port as service name.
937
+ * @param[in] disable_line_protocol_validation disable line protocol version
886
938
*/
887
- opts (protocol protocol, utf8_view host, utf8_view port) noexcept
939
+ opts (
940
+ protocol protocol,
941
+ utf8_view host,
942
+ utf8_view port,
943
+ bool disable_line_protocol_validation = false ) noexcept
888
944
: _impl{::line_sender_opts_new_service (
889
945
static_cast <::line_sender_protocol>(protocol),
890
946
host._impl ,
891
947
port._impl )}
892
948
{
893
949
line_sender_error::wrapped_call (
894
950
::line_sender_opts_user_agent, _impl, _user_agent::name ());
951
+ if (disable_line_protocol_validation)
952
+ {
953
+ line_sender_error::wrapped_call (
954
+ ::line_sender_opts_disable_line_protocol_validation, _impl);
955
+ }
895
956
}
896
957
897
958
opts (const opts& other) noexcept
@@ -1194,13 +1255,23 @@ class line_sender
1194
1255
return {opts::from_env ()};
1195
1256
}
1196
1257
1197
- line_sender (protocol protocol, utf8_view host, uint16_t port)
1198
- : line_sender{opts{protocol, host, port}}
1258
+ line_sender (
1259
+ protocol protocol,
1260
+ utf8_view host,
1261
+ uint16_t port,
1262
+ bool disable_line_protocol_validation = false )
1263
+ : line_sender{
1264
+ opts{protocol, host, port, disable_line_protocol_validation}}
1199
1265
{
1200
1266
}
1201
1267
1202
- line_sender (protocol protocol, utf8_view host, utf8_view port)
1203
- : line_sender{opts{protocol, host, port}}
1268
+ line_sender (
1269
+ protocol protocol,
1270
+ utf8_view host,
1271
+ utf8_view port,
1272
+ bool disable_line_protocol_validation = false )
1273
+ : line_sender{
1274
+ opts{protocol, host, port, disable_line_protocol_validation}}
1204
1275
{
1205
1276
}
1206
1277
0 commit comments