Skip to content

Remove Timestamp::Now #66

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

Merged
merged 7 commits into from
Aug 21, 2020
Merged

Remove Timestamp::Now #66

merged 7 commits into from
Aug 21, 2020

Conversation

Empty2k12
Copy link
Collaborator

Description

Undoes #51

Due to inconsistencies between InfluxDb v1.7 and InfluxDb v1.8, I have decided to remove the Timestamp::Now value. Previously, when using this, InfluxDb would use the current system time in RFC3339.

The new way of using the current time for a write is to calculate the time in Rust and send it to InfluxDb along the request. This way, any delay on the way to InfluxDb is also not an issue any more and the time of creating the Query in Rust is the one being used.

One simple piece of code to achieve this is

use influxdb::{Timestamp};
use std::time::{SystemTime, UNIX_EPOCH};
let start = SystemTime::now();
let since_the_epoch = start
  .duration_since(UNIX_EPOCH)
  .expect("Time went backwards");
let query = Timestamp::Milliseconds(since_the_epoch)
    .into_query("weather")
    .add_field("temperature", 82);

The library could supply helper functions to calculate the timestamp to be used together with the existing Timestamp initializers.

Checklist

  • Formatted code using cargo fmt --all
  • Linted code using clippy cargo clippy --all-targets --all-features -- -D warnings
  • Updated README.md using cargo readme > README.md
  • Reviewed the diff. Did you leave any print statements or unnecessary comments?
  • Any unfinished work that warrants a separate issue captured in an issue with a TODO code comment

@Empty2k12 Empty2k12 merged commit ac6f3c7 into master Aug 21, 2020
@Empty2k12 Empty2k12 deleted the fix/timestamp-now branch August 21, 2020 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant