Skip to content

Commit cb7f08c

Browse files
msrd0Empty2k12
andauthored
Add InfluxDbWriteable procedural derive macro (#23)
* cargo workspace * introduce InfluxDbWriteable * basic derive stuff * first writeable derive attempt * add test for the ci to run * add derive feature in travis * update version to 0.0.5 * fix some stuff * fix failing doc test * no default features, run tests with all features * typo * remove some warnings * cargo fmt * cargo readme * cargo readme is incompetent * Fix build hopefully * Debug CI * Debug Ci 2 * Debug Ci 3 * Debug Ci 4 * Debug Ci 5 * Stop using cargo-travis * Do stuff * tidy up * Test both crates * remove an `&` * travis närvt * first attempt at tags * specify the attributes * add usefull derives to Timestamp * the world is a brocken * that merge went well ..... * Refactor Tests * fix derp * Painstakingly fix tests and make chrono a required dependency * Fix lint warning * Update README * More fixes * apply @Empty2k12's suggestions && fix compile issue with no features * proper difference between field and tag * introduce krate method * progress * add field / tag test * cosmetic updates * fixed * fix clippy and fmt Co-authored-by: Gero Gerke <11deutron11@gmail.com>
1 parent 90f5f95 commit cb7f08c

24 files changed

+516
-236
lines changed

.travis.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,13 @@ matrix:
5151
script:
5252
- bash auxiliary/check_readme_consistency.sh
5353

54-
script: |
55-
export RUST_BACKTRACE=1 &&
56-
cargo build &&
57-
cargo test --all-features &&
58-
cargo doc --no-deps
54+
script:
55+
- export RUST_BACKTRACE=1
56+
- cd influxdb
57+
- cargo build
58+
- cargo test --all --all-features
59+
- cargo doc --no-deps
60+
- cd ../influxdb_derive
61+
- cargo build
62+
- cargo test --all --all-features
63+
- cargo doc --no-deps

Cargo.toml

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,8 @@
1-
[package]
2-
name = "influxdb"
3-
version = "0.0.6"
4-
authors = ["Gero Gerke <11deutron11@gmail.com>"]
5-
edition = "2018"
6-
description = "InfluxDB Driver for Rust"
7-
keywords = ["influxdb", "database", "influx"]
8-
license = "MIT"
9-
readme = "README.md"
10-
include = ["src/**/*", "tests/**/*", "Cargo.toml", "LICENSE"]
11-
repository = "https://github.com/Empty2k12/influxdb-rust"
1+
# -*- eval: (cargo-minor-mode 1) -*-
122

13-
[badges]
14-
travis-ci = { repository = "Empty2k12/influxdb-rust", branch = "master" }
3+
[workspace]
4+
members = ["influxdb", "influxdb_derive"]
155

16-
[dependencies]
17-
chrono = { version = "0.4.10", optional = true }
18-
failure = "0.1.6"
19-
futures = "0.3.4"
20-
reqwest = { version = "0.10.1", features = ["json"] }
21-
serde = { version = "1.0.104", features = ["derive"], optional = true }
22-
serde_json = { version = "1.0.46", optional = true }
23-
regex = "1.3.4"
24-
lazy_static = "1.4.0"
25-
26-
# This is a temporary work around to fix a Failure-derive compilation error
27-
# Should be removed when https://github.com/Empty2k12/influxdb-rust/issues/48 is being done
28-
quote = "=1.0.2"
29-
30-
[features]
31-
use-serde = ["serde", "serde_json"]
32-
chrono_timestamps = ["chrono"]
33-
default = ["use-serde"]
34-
35-
[dev-dependencies]
36-
tokio = { version = "0.2.11", features = ["macros"] }
6+
[patch.crates-io]
7+
influxdb = { path = "./influxdb" }
8+
influxdb_derive = { path = "./influxdb_derive" }

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ Pull requests are always welcome. See [Contributing](https://github.com/Empty2k1
3939
- Optional Serde Support for Deserialization
4040
- Running multiple queries in one request (e.g. `SELECT * FROM weather_berlin; SELECT * FROM weather_london`)
4141
- Authenticated and Unauthenticated Connections
42-
- Optional conversion between `Timestamp` and `Chrono::DateTime<Utc>` via `chrono_timestamps` compilation feature
4342
- `async`/`await` support
43+
- `#[derive(InfluxDbWriteable)]` Derive Macro for Writing / Reading into Structs
4444

4545
### Planned Features
4646

4747
- Read Query Builder instead of supplying raw queries
48-
- `#[derive(InfluxDbReadable)]` and `#[derive(InfluxDbWriteable)]` proc macros
4948

5049
## Quickstart
5150

@@ -59,6 +58,7 @@ For an example with using Serde deserialization, please refer to [serde_integrat
5958

6059
```rust
6160
use influxdb::{Client, Query, Timestamp};
61+
use influxdb::InfluxDbWriteable;
6262

6363
// Create a Client with URL `http://localhost:8086`
6464
// and database name `test`
@@ -67,7 +67,7 @@ let client = Client::new("http://localhost:8086", "test");
6767
// Let's write something to InfluxDB. First we're creating a
6868
// WriteQuery to write some data.
6969
// This creates a query which writes a new measurement into a series called `weather`
70-
let write_query = Query::write_query(Timestamp::Now, "weather")
70+
let write_query = Timestamp::Now.into_query("weather")
7171
.add_field("temperature", 82);
7272

7373
// Submit the query to InfluxDB.

auxiliary/check_readme_consistency.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/bash
1+
#!/bin/bash
22

3-
cargo readme > README.md.expected
3+
cargo readme -r influxdb -t ../README.tpl > README.md.expected
44

55
diff README.md README.md.expected
66

@@ -9,6 +9,6 @@ then
99
echo 'README.md is up to date!'
1010
exit 0
1111
else
12-
echo 'README.md out of date. Run "cargo readme > README.md" and commit again.'
12+
echo 'README.md out of date. Run "cargo readme -r influxdb -t ../README.tpl > README.md" and commit again.'
1313
exit 1
14-
fi
14+
fi

influxdb/Cargo.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# -*- eval: (cargo-minor-mode 1) -*-
2+
3+
[package]
4+
name = "influxdb"
5+
version = "0.0.6"
6+
authors = ["Gero Gerke <11deutron11@gmail.com>"]
7+
edition = "2018"
8+
description = "InfluxDB Driver for Rust"
9+
keywords = ["influxdb", "database", "influx"]
10+
license = "MIT"
11+
readme = "README.md"
12+
include = ["src/**/*", "tests/**/*", "Cargo.toml", "LICENSE"]
13+
repository = "https://github.com/Empty2k12/influxdb-rust"
14+
15+
[badges]
16+
travis-ci = { repository = "Empty2k12/influxdb-rust", branch = "master" }
17+
18+
[dependencies]
19+
chrono = { version = "0.4.10", features = ["serde"] }
20+
failure = "0.1.6"
21+
futures = "0.3.4"
22+
influxdb_derive = { version = "0.0.1", optional = true }
23+
reqwest = { version = "0.10.1", features = ["json"] }
24+
serde = { version = "1.0.104", features = ["derive"], optional = true }
25+
serde_json = { version = "1.0.46", optional = true }
26+
regex = "1.3.4"
27+
lazy_static = "1.4.0"
28+
29+
[features]
30+
use-serde = ["serde", "serde_json"]
31+
default = ["use-serde"]
32+
derive = ["influxdb_derive"]
33+
34+
[dev-dependencies]
35+
tokio = { version = "0.2.11", features = ["macros"] }

influxdb/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE

influxdb/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../README.md

src/client/mod.rs renamed to influxdb/src/client/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,13 @@ impl Client {
162162
///
163163
/// ```rust,no_run
164164
/// use influxdb::{Client, Query, Timestamp};
165+
/// use influxdb::InfluxDbWriteable;
165166
///
166167
/// # #[tokio::main]
167168
/// # async fn main() -> Result<(), failure::Error> {
168169
/// let client = Client::new("http://localhost:8086", "test");
169-
/// let query = Query::write_query(Timestamp::Now, "weather")
170+
/// let query = Timestamp::Now
171+
/// .into_query("weather")
170172
/// .add_field("temperature", 82);
171173
/// let results = client.query(&query).await?;
172174
/// # Ok(())
File renamed without changes.

0 commit comments

Comments
 (0)