Skip to content

Commit 80fbe43

Browse files
committed
Rust API doc improvements
1 parent 212a0d7 commit 80fbe43

File tree

4 files changed

+58
-13
lines changed

4 files changed

+58
-13
lines changed

include/questdb/ingress/line_sender.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ line_sender* line_sender_build(
796796
* The accepted set of keys and values is the same as for the opt's API.
797797
* E.g. "tcp::addr=host:port;user=alice;password=secret;tls_ca=os_roots;"
798798
*
799-
* For full list of options, search this header for `bool line_sender_opts_`.
799+
* For full list of keys and values, search this header for `bool line_sender_opts_`.
800800
*/
801801
LINESENDER_API
802802
line_sender* line_sender_from_conf(

questdb-rs/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ keywords = ["questdb", "ilp", "client-library"]
1010
categories = ["database"]
1111
authors = ["Adam Cimarosti <[email protected]>"]
1212

13+
[package.metadata.docs.rs]
14+
all-features = true
15+
1316
[lib]
1417
name = "questdb"
1518
crate-type = ["lib"]

questdb-rs/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# QuestDB Client Library for Rust
22

3+
Official Rust client for [QuestDB](https://questdb.io/), an open-source SQL database designed to process time-series data, faster.
4+
5+
The client library is designed for fast ingestion of data into QuestDB via the InfluxDB Line Protocol (ILP).
6+
7+
* [QuestDB Database docs](https://questdb.io/docs/)
8+
* [ILP docs](https://questdb.io/docs/reference/api/ilp/overview/)
9+
310
## Getting Started
411

512
To start using `questdb-rs` add it to your `Cargo.toml`:
@@ -23,11 +30,10 @@ use questdb::{
2330
ingress::{
2431
Sender,
2532
Buffer,
26-
SenderBuilder,
2733
TimestampNanos}};
2834

2935
fn main() -> Result<()> {
30-
let mut sender = SenderBuilder::new_tcp("localhost", 9009).build()?;
36+
let mut sender = Sender::from_conf("http::addr=localhost:9000;")?;
3137
let mut buffer = Buffer::new();
3238
buffer
3339
.table("sensors")?

questdb-rs/src/ingress/mod.rs

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,20 @@
2929
//! (ILP) over TCP.
3030
//!
3131
//! To get started:
32-
//! * Connect to QuestDB by creating a [`Sender`] object.
32+
//! * Connect to QuestDB by creating a [`Sender`] object, usually via [`Sender::from_conf`].
3333
//! * Populate a [`Buffer`] with one or more rows of data.
3434
//! * Send the buffer via the Sender's [`flush`](Sender::flush) method.
3535
//!
36-
//! ```no_run
36+
//! ```rust no_run
3737
//! use questdb::{
3838
//! Result,
3939
//! ingress::{
4040
//! Sender,
4141
//! Buffer,
42-
//! SenderBuilder,
4342
//! TimestampNanos}};
44-
//!
43+
//!
4544
//! fn main() -> Result<()> {
46-
//! let mut sender = SenderBuilder::new_tcp("localhost", 9009).build()?;
45+
//! let mut sender = Sender::from_conf("http::addr=localhost:9000;")?;
4746
//! let mut buffer = Buffer::new();
4847
//! buffer
4948
//! .table("sensors")?
@@ -1325,7 +1324,7 @@ impl Default for Buffer {
13251324

13261325
/// Connects to a QuestDB instance and inserts data via the ILP protocol.
13271326
///
1328-
/// * To construct an instance, use the [`SenderBuilder`].
1327+
/// * To construct an instance, use [`Sender::from_conf`] or the [`SenderBuilder`].
13291328
/// * To prepare messages, use [`Buffer`] objects.
13301329
/// * To send messages, call the [`flush`](Sender::flush) method.
13311330
pub struct Sender {
@@ -1724,10 +1723,24 @@ pub struct SenderBuilder {
17241723

17251724
impl SenderBuilder {
17261725
/// Create a new `SenderBuilder` instance from configuration string.
1727-
/// The format of the string is: "tcp::addr=host:port;ket=value;...;"
1728-
/// Alongside "tcp" you can also specify "tcps", "http", and "https".
1726+
///
1727+
/// The format of the string is: `"http::addr=host:port;ket=value;...;"`.
1728+
///
1729+
/// Alongside `"http"` you can also specify `"https"`, `"tcp"`, and `"tcps"`.
1730+
///
1731+
/// HTTP is recommended in most cases as is provides better error feedback
1732+
/// allows controlling transactions. TCP can sometimes be faster in higher-latency
1733+
/// networks, but misses out on a number of features.
1734+
///
17291735
/// The accepted set of keys and values is the same as for the `SenderBuilder`'s API.
1730-
/// E.g. "tcp::addr=host:port;user=alice;password=secret;tls_ca=os_roots;"
1736+
///
1737+
/// E.g. `"http::addr=host:port;user=alice;password=secret;tls_ca=os_roots;"`.
1738+
///
1739+
/// If you prefer, you can also load the configuration from an environment variable.
1740+
/// See [`SenderBuilder::from_env`].
1741+
///
1742+
/// Once a `SenderBuilder` is created from a string (or from the environment variable)
1743+
/// it can be further customized before calling [`SenderBuilder::build`].
17311744
pub fn from_conf<T: AsRef<str>>(conf: T) -> Result<Self> {
17321745
let conf = conf.as_ref();
17331746
let conf = questdb_confstr::parse_conf_str(conf)
@@ -1885,6 +1898,8 @@ impl SenderBuilder {
18851898

18861899
/// Create a new `SenderBuilder` instance from configuration string read from the
18871900
/// `QDB_CLIENT_CONF` environment variable.
1901+
///
1902+
/// The format of the string is the same as for [`SenderBuilder::from_conf`].
18881903
pub fn from_env() -> Result<Self> {
18891904
let conf = std::env::var("QDB_CLIENT_CONF").map_err(|_| {
18901905
error::fmt!(ConfigError, "Environment variable QDB_CLIENT_CONF not set.")
@@ -2607,12 +2622,31 @@ impl F64Serializer {
26072622
}
26082623

26092624
impl Sender {
2610-
/// Create a new `Sender` from configuration parameters.
2625+
/// Create a new `Sender` instance from configuration string.
2626+
///
2627+
/// The format of the string is: `"http::addr=host:port;key=value;...;"`.
2628+
///
2629+
/// Alongside `"http"` you can also specify `"https"`, `"tcp"`, and `"tcps"`.
2630+
///
2631+
/// HTTP is recommended in most cases as is provides better error feedback
2632+
/// allows controlling transactions. TCP can sometimes be faster in higher-latency
2633+
/// networks, but misses out on a number of features.
2634+
///
2635+
/// The accepted set of keys and values is the same as for the opt's API.
2636+
///
2637+
/// E.g. `"http::addr=host:port;user=alice;password=secret;tls_ca=os_roots;"`.
2638+
///
2639+
/// For full list of keys and values, see the [`SenderBuilder`] documentation:
2640+
/// The builder API and the configuration string API are equivalent.
2641+
///
2642+
/// If you prefer, you can also load the configuration from an environment variable.
2643+
/// See [`Sender::from_env`].
26112644
pub fn from_conf<T: AsRef<str>>(conf: T) -> Result<Self> {
26122645
SenderBuilder::from_conf(conf)?.build()
26132646
}
26142647

26152648
/// Create a new `Sender` from the `QDB_CLIENT_CONF` environment variable.
2649+
/// The format is the same as that taken by [`Sender::from_conf`].
26162650
pub fn from_env() -> Result<Self> {
26172651
SenderBuilder::from_env()?.build()
26182652
}
@@ -2706,6 +2740,8 @@ impl Sender {
27062740
///
27072741
/// This is because QuestDB does not support transactions spanning multiple
27082742
/// tables.
2743+
///
2744+
/// Note that transactional flushes are only supported for ILP over HTTP.
27092745
#[cfg(feature = "ilp-over-http")]
27102746
pub fn flush_and_keep_with_flags(&mut self, buf: &Buffer, transactional: bool) -> Result<()> {
27112747
self.flush_impl(buf, transactional)

0 commit comments

Comments
 (0)