Browse Source

add a drop deadline to exit routine

master
Jonathan Strong 3 years ago
parent
commit
c47903d464
2 changed files with 13 additions and 1 deletions
  1. +1
    -1
      Cargo.toml
  2. +12
    -0
      src/lib.rs

+ 1
- 1
Cargo.toml View File

@@ -1,6 +1,6 @@
[package]
name = "influx-writer"
version = "0.12.0"
version = "0.13.0"
authors = ["Jonathan Strong <jonathan.strong@gmail.com>"]
edition = "2018"



+ 12
- 0
src/lib.rs View File

@@ -33,6 +33,8 @@ use pretty_toa::ThousandsSep;
/// previously `-999.0` had been used.
pub const SKIP_NAN_VALUES: bool = true;

pub const DROP_DEADLINE: Duration = Duration::from_secs(30);

pub type Credentials = hyper::header::Authorization<hyper::header::Basic>;

/// Created this so I know what types can be passed through the
@@ -741,6 +743,16 @@ impl InfluxWriter {
"elapsed" => %format_args!("{:?}", loop_time - start));
break 'event
}

if loop_time.saturating_duration_since(start) > DROP_DEADLINE {
crit!(logger, "drop deadline exceeded! commencing dirty exit :( ";
"elapsed" => ?(loop_time.saturating_duration_since(start)),
"n outstanding" => n_outstanding,
"backlog.len()" => backlog.len(),
);
break 'event
}

if loop_time - hb > Duration::from_secs(5) {
info!(logger, "InfluxWriter still clearing backlog ..";
"n_outstanding" => n_outstanding,


Loading…
Cancel
Save