diff --git a/Cargo.toml b/Cargo.toml index e40502a..9b821ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,10 +59,10 @@ serde_json = "1.0.68" serde_plain = "1.0.0" surf = { version = "2.3.1", optional = true } -[dependencies.chrono] +[dependencies.time] default-features = false -features = ["clock", "serde"] -version = "0.4.19" +features = ["std", "serde"] +version = "0.3.30" [dependencies.reqwest] default-features = false diff --git a/src/api.rs b/src/api.rs index ad1b006..1c82548 100644 --- a/src/api.rs +++ b/src/api.rs @@ -3,7 +3,6 @@ use std::collections::HashMap; use std::default::Default; -use chrono::Utc; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] @@ -29,7 +28,7 @@ pub struct Feature { pub strategies: Vec, pub variants: Option>, #[serde(rename = "createdAt")] - pub created_at: Option>, + pub created_at: Option, } #[derive(Clone, Default, Serialize, Deserialize, Debug)] @@ -85,7 +84,7 @@ pub struct Registration { #[serde(rename = "sdkVersion")] pub sdk_version: String, pub strategies: Vec, - pub started: chrono::DateTime, + pub started: time::OffsetDateTime, pub interval: u64, } @@ -102,7 +101,7 @@ impl Default for Registration { instance_id: "".into(), sdk_version: "unleash-client-rust-0.1.0".into(), strategies: vec![], - started: Utc::now(), + started: time::OffsetDateTime::now_utc(), interval: 15 * 1000, } } @@ -132,8 +131,8 @@ pub struct ToggleMetrics { #[derive(Serialize, Deserialize, Debug)] pub struct MetricsBucket { - pub start: chrono::DateTime, - pub stop: chrono::DateTime, + pub start: time::OffsetDateTime, + pub stop: time::OffsetDateTime, pub toggles: HashMap, } diff --git a/src/client.rs b/src/client.rs index ce508cc..f08eeb3 100644 --- a/src/client.rs +++ b/src/client.rs @@ -8,7 +8,6 @@ use std::sync::{Arc, Mutex}; use std::time::Duration; use arc_swap::ArcSwapOption; -use chrono::Utc; use enum_map::{EnumArray, EnumMap}; use futures_timer::Delay; use log::{debug, trace, warn}; @@ -202,7 +201,7 @@ pub struct CachedState where F: EnumArray, { - start: chrono::DateTime, + start: time::OffsetDateTime, // user supplies F defining the features they need // The default value of F is defined as 'fallback to string lookups'. features: EnumMap, @@ -668,7 +667,7 @@ where &self, features: Vec, ) -> Result, Box> { - let now = Utc::now(); + let now = time::OffsetDateTime::now_utc(); trace!("memoize: start with {} features", features.len()); let source_strategies = self.strategies.lock().unwrap(); let mut unenumerated_features: HashMap = HashMap::new();