Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add InfluxDbWriteable procedural derive macro #23

Merged
merged 57 commits into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
0a797f0
cargo workspace
msrd0 Oct 9, 2019
071aa67
introduce InfluxDbWriteable
msrd0 Oct 9, 2019
0734d38
basic derive stuff
msrd0 Oct 9, 2019
c50812a
Merge remote-tracking branch 'origin/master' into add-proc-macro-derive
msrd0 Oct 9, 2019
8c8bc03
first writeable derive attempt
msrd0 Oct 9, 2019
f84b523
add test for the ci to run
msrd0 Oct 9, 2019
e13cbde
add derive feature in travis
msrd0 Oct 9, 2019
92dd0c7
Merge remote-tracking branch 'upstream/master' into add-proc-macro-de…
msrd0 Oct 12, 2019
9c93c13
update version to 0.0.5
msrd0 Oct 12, 2019
6082e22
fix some stuff
msrd0 Oct 12, 2019
8458446
fix failing doc test
msrd0 Oct 12, 2019
70a64ef
no default features, run tests with all features
msrd0 Oct 12, 2019
7931440
typo
msrd0 Oct 12, 2019
2b7b6e9
remove some warnings
msrd0 Oct 12, 2019
f3524f4
cargo fmt
msrd0 Oct 12, 2019
42406d6
cargo readme
msrd0 Oct 13, 2019
0834cf6
cargo readme is incompetent
msrd0 Oct 13, 2019
3cafac4
Fix build hopefully
Empty2k12 Oct 15, 2019
3adb833
Debug CI
Empty2k12 Oct 15, 2019
746c24a
Debug Ci 2
Empty2k12 Oct 15, 2019
d412695
Debug Ci 3
Empty2k12 Oct 15, 2019
5307c3d
Debug Ci 4
Empty2k12 Oct 15, 2019
65eabae
Debug Ci 5
Empty2k12 Oct 15, 2019
989f2a3
Stop using cargo-travis
Empty2k12 Oct 17, 2019
ba24ff2
Do stuff
Empty2k12 Oct 17, 2019
6ee5a06
Merge remote-tracking branch 'upstream/master' into add-proc-macro-de…
msrd0 Oct 22, 2019
efc6ec3
tidy up
msrd0 Oct 22, 2019
1150822
Test both crates
Empty2k12 Oct 22, 2019
0db03f9
Merge remote-tracking branch 'upstream/master' into add-proc-macro-de…
msrd0 Oct 26, 2019
bb7de21
remove an `&`
msrd0 Oct 26, 2019
f11552f
travis närvt
msrd0 Oct 26, 2019
c2fd9a9
first attempt at tags
msrd0 Oct 26, 2019
7495f8b
specify the attributes
msrd0 Oct 26, 2019
1d0aa36
add usefull derives to Timestamp
msrd0 Oct 26, 2019
f1fbef7
Merge remote-tracking branch 'upstream/master' into add-proc-macro-de…
msrd0 Oct 26, 2019
35d8bc5
the world is a brocken
msrd0 Oct 27, 2019
42cc777
Merge remote-tracking branch 'upstream/master' into add-proc-macro-de…
msrd0 Oct 27, 2019
c642cad
that merge went well .....
msrd0 Oct 27, 2019
aefefec
Refactor Tests
Empty2k12 Oct 28, 2019
3ca5ffd
Merge branch 'add-proc-macro-derive' of github.com:msrd0/influxdb-rus…
Empty2k12 Oct 28, 2019
222ed1b
Merge remote-tracking branch 'upstream/master' into add-proc-macro-de…
msrd0 Oct 30, 2019
e7408fd
Merge remote-tracking branch 'main/master' into add-proc-macro-derive
Empty2k12 Nov 1, 2019
6e3dd1a
fix derp
Empty2k12 Nov 1, 2019
4207cc4
Painstakingly fix tests and make chrono a required dependency
Empty2k12 Nov 1, 2019
5287b51
Fast forward and fixes
Empty2k12 Mar 16, 2020
00ce9aa
Fix lint warning
Empty2k12 Mar 16, 2020
c7f7ed8
Update README
Empty2k12 Mar 16, 2020
7ff4258
More fixes
Empty2k12 Mar 16, 2020
a01d639
apply @Empty2k12's suggestions && fix compile issue with no features
msrd0 Mar 16, 2020
83fe5fd
proper difference between field and tag
msrd0 Mar 16, 2020
8a06210
introduce krate method
msrd0 Mar 16, 2020
b8c80d1
progress
Empty2k12 Mar 17, 2020
936346d
Merge remote-tracking branch 'origin/add-proc-macro-derive' into add-…
Empty2k12 Mar 17, 2020
f6296aa
add field / tag test
Empty2k12 Mar 17, 2020
ef4852b
cosmetic updates
Empty2k12 Mar 17, 2020
6f261c4
fixed
Empty2k12 Mar 17, 2020
425d5b1
fix clippy and fmt
Empty2k12 Mar 17, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ matrix:
script:
- bash auxiliary/check_readme_consistency.sh

script: |
export RUST_BACKTRACE=1 &&
cargo build &&
cargo test --all-features &&
cargo doc --no-deps
script:
- export RUST_BACKTRACE=1
- cd influxdb
- cargo build
- cargo test --all --all-features
- cargo doc --no-deps
- cd ../influxdb_derive
- cargo build
- cargo test --all --all-features
- cargo doc --no-deps
41 changes: 6 additions & 35 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,36 +1,7 @@
[package]
name = "influxdb"
version = "0.0.6"
authors = ["Gero Gerke <11deutron11@gmail.com>"]
edition = "2018"
description = "InfluxDB Driver for Rust"
keywords = ["influxdb", "database", "influx"]
license = "MIT"
readme = "README.md"
include = ["src/**/*", "tests/**/*", "Cargo.toml", "LICENSE"]
repository = "https://github.com/Empty2k12/influxdb-rust"
# -*- eval: (cargo-minor-mode 1) -*-
[workspace]
members = ["influxdb", "influxdb_derive"]

[badges]
travis-ci = { repository = "Empty2k12/influxdb-rust", branch = "master" }

[dependencies]
chrono = { version = "0.4.10", optional = true }
failure = "0.1.6"
futures = "0.3.4"
reqwest = { version = "0.10.1", features = ["json"] }
serde = { version = "1.0.104", features = ["derive"], optional = true }
serde_json = { version = "1.0.46", optional = true }
regex = "1.3.4"
lazy_static = "1.4.0"

# This is a temporary work around to fix a Failure-derive compilation error
# Should be removed when https://github.com/Empty2k12/influxdb-rust/issues/48 is being done
quote = "=1.0.2"

[features]
use-serde = ["serde", "serde_json"]
chrono_timestamps = ["chrono"]
default = ["use-serde"]

[dev-dependencies]
tokio = { version = "0.2.11", features = ["macros"] }
[patch.crates-io]
influxdb = { path = "./influxdb" }
influxdb_derive = { path = "./influxdb_derive" }
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ Pull requests are always welcome. See [Contributing](https://github.com/Empty2k1
- Optional Serde Support for Deserialization
- Running multiple queries in one request (e.g. `SELECT * FROM weather_berlin; SELECT * FROM weather_london`)
- Authenticated and Unauthenticated Connections
- Optional conversion between `Timestamp` and `Chrono::DateTime<Utc>` via `chrono_timestamps` compilation feature
- `async`/`await` support
- `#[derive(InfluxDbWriteable)]` Derive Macro for Writing / Reading into Structs

### Planned Features

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

## Quickstart

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

```rust
use influxdb::{Client, Query, Timestamp};
use influxdb::InfluxDbWriteable;

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

// Submit the query to InfluxDB.
Expand Down
8 changes: 4 additions & 4 deletions auxiliary/check_readme_consistency.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/bash
#!/bin/bash

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

diff README.md README.md.expected

Expand All @@ -9,6 +9,6 @@ then
echo 'README.md is up to date!'
exit 0
else
echo 'README.md out of date. Run "cargo readme > README.md" and commit again.'
echo 'README.md out of date. Run "cargo readme -r influxdb -t ../README.tpl > README.md" and commit again.'
exit 1
fi
fi
39 changes: 39 additions & 0 deletions influxdb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- eval: (cargo-minor-mode 1) -*-

[package]
name = "influxdb"
version = "0.0.5"
authors = ["Gero Gerke <11deutron11@gmail.com>"]
edition = "2018"
description = "InfluxDB Driver for Rust"
keywords = ["influxdb", "database", "influx"]
license = "MIT"
readme = "README.md"
include = ["src/**/*", "tests/**/*", "Cargo.toml", "LICENSE"]
repository = "https://github.com/Empty2k12/influxdb-rust"

[badges]
travis-ci = { repository = "Empty2k12/influxdb-rust", branch = "master" }

[dependencies]
chrono = { version = "0.4.10", features = ["serde"] }
failure = "0.1.6"
futures = "0.3.4"
influxdb_derive = { version = "0.0.1", optional = true }
reqwest = { version = "0.10.1", features = ["json"] }
serde = { version = "1.0.104", features = ["derive"], optional = true }
serde_json = { version = "1.0.46", optional = true }
regex = "1.3.4"
lazy_static = "1.4.0"

# This is a temporary work around to fix a Failure-derive compilation error
# Should be removed when https://github.com/Empty2k12/influxdb-rust/issues/48 is being done
quote = "1.0.3"
msrd0 marked this conversation as resolved.
Show resolved Hide resolved

[features]
use-serde = ["serde", "serde_json"]
default = ["use-serde"]
derive = ["influxdb_derive"]

[dev-dependencies]
tokio = { version = "0.2.11", features = ["macros"] }
1 change: 1 addition & 0 deletions influxdb/LICENSE
1 change: 1 addition & 0 deletions influxdb/README.md
4 changes: 3 additions & 1 deletion src/client/mod.rs → influxdb/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,13 @@ impl Client {
///
/// ```rust,no_run
/// use influxdb::{Client, Query, Timestamp};
/// use influxdb::InfluxDbWriteable;
///
/// # #[tokio::main]
/// # async fn main() -> Result<(), failure::Error> {
/// let client = Client::new("http://localhost:8086", "test");
/// let query = Query::write_query(Timestamp::Now, "weather")
/// let query = Timestamp::Now
/// .into_query("weather")
/// .add_field("temperature", 82);
/// let results = client.query(&query).await?;
/// # Ok(())
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions src/lib.rs → influxdb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
//! - Optional Serde Support for Deserialization
//! - Running multiple queries in one request (e.g. `SELECT * FROM weather_berlin; SELECT * FROM weather_london`)
//! - Authenticated and Unauthenticated Connections
//! - Optional conversion between `Timestamp` and `Chrono::DateTime<Utc>` via `chrono_timestamps` compilation feature
//! - `async`/`await` support
//! - `#[derive(InfluxDbWriteable)]` Derive Macro for Writing / Reading into Structs
//!
//! ## Planned Features
//!
//! - Read Query Builder instead of supplying raw queries
//! - `#[derive(InfluxDbReadable)]` and `#[derive(InfluxDbWriteable)]` proc macros
//!
//! # Quickstart
//!
Expand All @@ -30,6 +29,7 @@
//!
//! ```rust,no_run
//! use influxdb::{Client, Query, Timestamp};
//! use influxdb::InfluxDbWriteable;
//!
//! # #[tokio::main]
//! # async fn main() {
Expand All @@ -40,7 +40,7 @@
//! // Let's write something to InfluxDB. First we're creating a
//! // WriteQuery to write some data.
//! // This creates a query which writes a new measurement into a series called `weather`
//! let write_query = Query::write_query(Timestamp::Now, "weather")
//! let write_query = Timestamp::Now.into_query("weather")
//! .add_field("temperature", 82);
//!
//! // Submit the query to InfluxDB.
Expand Down Expand Up @@ -83,7 +83,7 @@ pub use error::Error;
pub use query::{
read_query::ReadQuery,
write_query::{Type, WriteQuery},
Query, QueryType, QueryTypes, Timestamp, ValidQuery,
InfluxDbWriteable, Query, QueryType, QueryTypes, Timestamp, ValidQuery,
};

#[cfg(feature = "use-serde")]
Expand Down
File renamed without changes.
File renamed without changes.
Loading