You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+62-29Lines changed: 62 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,21 @@
4
4
5
5
A modern C++20 [InfluxDB](https://www.influxdata.com/time-series-platform/influxdb/) client via [C++ REST SDK](https://github.com/Microsoft/cpprestsdk) + a C wrapper of the asynchronous API as a shared library.
6
6
7
+
## C++ Standard Requirements
8
+
9
+
**This project requires C++20 or later.**
10
+
11
+
- Minimum compiler versions:
12
+
- GCC 11+
13
+
- Clang 14+
14
+
- MSVC 2019+ (19.29+) with `/std:c++20` or later
15
+
- The project uses C++20
16
+
- All dependencies are C++20 compatible
17
+
-**Note:** The legacy C++03 version is available in the [`v0.0.1-legacy`](https://github.com/d-led/influxdb-cpp-rest/releases/tag/v0.0.1-legacy) tag
18
+
7
19
See [the demo source](src/demo/main.cpp) for the current api example.
8
20
9
-
The unbatched aprroach (and without connection reuse) may not be sufficient in some situations, as without batching, about 200 lines/sec can be inserted.
21
+
The unbatched approach (and without connection reuse) may not be sufficient in some situations, as without batching, about 200 lines/sec can be inserted.
10
22
11
23
A batching api leans towards thousands inserts per second. Behind the scenes, the API uses [RxCpp](https://github.com/Reactive-Extensions/RxCpp) and [cppformat](https://github.com/fmtlib/fmt).
12
24
@@ -19,25 +31,35 @@ A batching api leans towards thousands inserts per second. Behind the scenes, th
key_value_pairs("my_count", i % MAX_VALUES_PER_TAG),
39
-
key_value_pairs("value", "hi!")
40
-
));
49
+
using namespace influxdb::api; // For line, key_value_pairs
50
+
using namespace std::string_literals;
51
+
using async_db = influxdb::async_api::simple_db; // Type alias to avoid ambiguity
52
+
53
+
auto db = async_db("http://localhost:8086"s, "my_db"s);
54
+
55
+
for (auto i = 0; i < 123456; ++i) {
56
+
db.insert(
57
+
line(
58
+
"my_measurements"s,
59
+
key_value_pairs("my_count"s, i % MAX_VALUES_PER_TAG),
60
+
key_value_pairs("value"s, "hi!"s)
61
+
)
62
+
);
41
63
}
42
64
```
43
65
@@ -51,13 +73,15 @@ Timestamps can be added as the last parameter to the `line` constructor, and onl
51
73
a serializable value on `TTimestamp::now()`. There is a default `std::chrono`-based implementation:
52
74
53
75
```cpp
54
-
line(
55
-
"my_measurements",
56
-
key_value_pairs("my_count", i % MAX_VALUES_PER_TAG),
57
-
key_value_pairs("value", "hi!"),
58
-
default_timestamp()
59
-
// ^^^^^^^^^^^^^^^^^^^
60
-
)
76
+
usingnamespaceinfluxdb::api;
77
+
using namespace std::string_literals;
78
+
79
+
line(
80
+
"my_measurements"s,
81
+
key_value_pairs("my_count"s, 42),
82
+
key_value_pairs("value"s, "hi!"s),
83
+
default_timestamp() // Optional: uses std::chrono for timestamps
84
+
)
61
85
```
62
86
63
87
`MAX_VALUES_PER_TAG` for demo purposes here, as there [is such a maximum](https://docs.influxdata.com/influxdb/v1.4/administration/config#max-values-per-tag-100000) and it has to be observed by the clients.
@@ -67,17 +91,23 @@ a serializable value on `TTimestamp::now()`. There is a default `std::chrono`-ba
0 commit comments