Update dependencies.

This commit is contained in:
Orne Brocaar 2023-09-18 16:21:22 +01:00
parent 0cf0a91699
commit a402b487f8
15 changed files with 457 additions and 371 deletions

662
Cargo.lock generated

File diff suppressed because it is too large Load Diff

14
api/rust/Cargo.toml vendored
View File

@ -15,17 +15,17 @@ json = ["pbjson", "pbjson-types", "serde"]
internal = []
[dependencies]
prost = "0.11"
prost-types = "0.11"
prost = "0.12"
prost-types = "0.12"
hex = "0.4"
rand = "0.8"
tonic = { version = "0.9", features = ["codegen", "prost"], default-features = false, optional = true }
tonic = { version = "0.10", features = ["codegen", "prost"], default-features = false, optional = true }
tokio = { version = "1.32", features = ["macros"], optional = true }
pbjson = { version = "0.5", optional = true }
pbjson-types = { version = "0.5", optional = true }
pbjson = { version = "0.6", optional = true }
pbjson-types = { version = "0.6", optional = true }
serde = { version = "1.0", optional = true }
[build-dependencies]
tonic-build = { version = "0.9", features = ["prost"], default-features = false }
pbjson-build = "0.5"
tonic-build = { version = "0.10", features = ["prost"], default-features = false }
pbjson-build = "0.6"

View File

@ -34,7 +34,7 @@ diesel = { version = "2.1", features = [
] }
diesel_migrations = { version = "2.1" }
r2d2 = "0.8"
bigdecimal = "0.3"
bigdecimal = "0.4"
redis = { version = "0.23", features = ["r2d2", "cluster", "tls-rustls"] }
# Logging
@ -72,14 +72,14 @@ tokio-reactor-trait = "1.1"
rdkafka = { version = "0.34", default-features = false, features = ["tokio", "cmake-build"] }
# gRPC and Protobuf
tonic = "0.9"
tonic-web = "0.9"
tonic-reflection = "0.9"
tonic = "0.10"
tonic-web = "0.10"
tonic-reflection = "0.10"
tokio = { version = "1.32", features = ["macros", "rt-multi-thread"] }
tokio-stream = "0.1"
prost-types = "0.11"
prost = "0.11"
pbjson-types = "0.5"
prost-types = "0.12"
prost = "0.12"
pbjson-types = "0.6"
# gRPC and HTTP multiplexing
warp = { version = "0.3", features = ["tls"], default-features = false }

View File

@ -260,7 +260,7 @@ impl ToProto<common::DeviceClass> for DeviceClass {
}
pub fn datetime_to_prost_timestamp(dt: &DateTime<Utc>) -> prost_types::Timestamp {
let ts = dt.timestamp_nanos();
let ts = dt.timestamp_nanos_opt().unwrap_or_default();
prost_types::Timestamp {
seconds: ts / 1_000_000_000,

View File

@ -1210,7 +1210,7 @@ impl Data {
self.device_session.last_device_status_request = Some(Utc::now().into());
}
Some(ts) => {
let ts: DateTime<Utc> = ts.clone().try_into()?;
let ts: DateTime<Utc> = ts.clone().try_into().map_err(anyhow::Error::msg)?;
let req_interval = Duration::from_secs(60 * 60 * 24)
/ self.device_profile.device_status_req_interval as u32;
@ -1563,7 +1563,8 @@ impl Data {
match &rd.w_f_cnt_last_request {
Some(v) => {
let last_req: DateTime<Utc> = v.clone().try_into()?;
let last_req: DateTime<Utc> =
v.clone().try_into().map_err(anyhow::Error::msg)?;
if last_req
< Utc::now()
.checked_sub_signed(chrono::Duration::hours(24))

View File

@ -68,8 +68,8 @@ impl Integration {
let client = aws_sdk_sns::Client::new(&config);
Ok(Integration {
json: match Encoding::from_i32(conf.encoding)
.ok_or_else(|| anyhow!("Invalid encoding"))?
json: match Encoding::try_from(conf.encoding)
.map_err(|_| anyhow!("Invalid encoding"))?
{
Encoding::Json => true,
Encoding::Protobuf => false,

View File

@ -32,8 +32,8 @@ impl Integration {
Ok(Integration {
timeout: Duration::from_secs(5),
json: match Encoding::from_i32(conf.encoding)
.ok_or_else(|| anyhow!("Invalid encoding"))?
json: match Encoding::try_from(conf.encoding)
.map_err(|_| anyhow!("Invalid encoding"))?
{
Encoding::Json => true,
Encoding::Protobuf => false,

View File

@ -49,8 +49,8 @@ impl Integration {
let auth_manager = AuthenticationManager::from(service_account);
Ok(Integration {
json: match Encoding::from_i32(conf.encoding)
.ok_or_else(|| anyhow!("Invalid encoding"))?
json: match Encoding::try_from(conf.encoding)
.map_err(|_| anyhow!("Invalid encoding"))?
{
Encoding::Json => true,
Encoding::Protobuf => false,

View File

@ -38,14 +38,14 @@ impl Integration {
Ok(Integration {
timeout: Duration::from_secs(5),
endpoint: conf.endpoint.clone(),
version: InfluxDbVersion::from_i32(conf.version)
.ok_or_else(|| anyhow!("Invalid version"))?,
version: InfluxDbVersion::try_from(conf.version)
.map_err(|_| anyhow!("Invalid version"))?,
db: conf.db.clone(),
username: conf.username.clone(),
password: conf.password.clone(),
retention_policy_name: conf.retention_policy_name.clone(),
precision: match InfluxDbPrecision::from_i32(conf.precision)
.ok_or_else(|| anyhow!("Invalid precision"))?
precision: match InfluxDbPrecision::try_from(conf.precision)
.map_err(|_| anyhow!("Invalid precision"))?
{
InfluxDbPrecision::Ns => "ns",
InfluxDbPrecision::U => "u",

View File

@ -43,7 +43,13 @@ impl Integration {
let di = pl.device_info.as_ref().unwrap();
info!(dev_eui = %di.dev_eui, "Forwarding join notification");
let ts: DateTime<Utc> = pl.time.as_ref().unwrap().clone().try_into()?;
let ts: DateTime<Utc> = pl
.time
.as_ref()
.unwrap()
.clone()
.try_into()
.map_err(anyhow::Error::msg)?;
let dev_eui = EUI64::from_str(&di.dev_eui)?;
let pl = client::UplinkRequest {
@ -67,7 +73,13 @@ impl Integration {
let di = pl.device_info.as_ref().unwrap();
info!(dev_eui = %di.dev_eui, "Forwarding updf message");
let ts: DateTime<Utc> = pl.time.as_ref().unwrap().clone().try_into()?;
let ts: DateTime<Utc> = pl
.time
.as_ref()
.unwrap()
.clone()
.try_into()
.map_err(anyhow::Error::msg)?;
let dev_eui = EUI64::from_str(&di.dev_eui)?;
let req = client::UplinkRequest {
@ -137,7 +149,13 @@ impl Integration {
) -> Result<()> {
let di = pl.device_info.as_ref().unwrap();
info!(dev_eui = %di.dev_eui, "Forwarding uplink meta-data");
let ts: DateTime<Utc> = pl.time.as_ref().unwrap().clone().try_into()?;
let ts: DateTime<Utc> = pl
.time
.as_ref()
.unwrap()
.clone()
.try_into()
.map_err(anyhow::Error::msg)?;
let dev_eui = EUI64::from_str(&di.dev_eui)?;
let req = client::UplinkRequest {
@ -223,7 +241,13 @@ impl Integration {
}
let di = pl.device_info.as_ref().unwrap();
let ts: DateTime<Utc> = pl.time.as_ref().unwrap().clone().try_into()?;
let ts: DateTime<Utc> = pl
.time
.as_ref()
.unwrap()
.clone()
.try_into()
.map_err(anyhow::Error::msg)?;
let dev_eui = EUI64::from_str(&di.dev_eui)?;
for p in &payloads {

View File

@ -227,7 +227,13 @@ impl IntegrationTrait for Integration {
let e = EventUp {
deduplication_id: Uuid::from_str(&pl.deduplication_id)?,
time: pl.time.as_ref().unwrap().clone().try_into()?,
time: pl
.time
.as_ref()
.unwrap()
.clone()
.try_into()
.map_err(anyhow::Error::msg)?,
tenant_id: Uuid::from_str(&di.tenant_id)?,
tenant_name: di.tenant_name.clone(),
application_id: Uuid::from_str(&di.application_id)?,
@ -271,7 +277,13 @@ impl IntegrationTrait for Integration {
let e = EventJoin {
deduplication_id: Uuid::from_str(&pl.deduplication_id)?,
time: pl.time.as_ref().unwrap().clone().try_into()?,
time: pl
.time
.as_ref()
.unwrap()
.clone()
.try_into()
.map_err(anyhow::Error::msg)?,
tenant_id: Uuid::from_str(&di.tenant_id)?,
tenant_name: di.tenant_name.clone(),
application_id: Uuid::from_str(&di.application_id)?,
@ -307,7 +319,13 @@ impl IntegrationTrait for Integration {
let e = EventAck {
queue_item_id: Uuid::from_str(&pl.queue_item_id)?,
deduplication_id: Uuid::from_str(&pl.deduplication_id)?,
time: pl.time.as_ref().unwrap().clone().try_into()?,
time: pl
.time
.as_ref()
.unwrap()
.clone()
.try_into()
.map_err(anyhow::Error::msg)?,
tenant_id: Uuid::from_str(&di.tenant_id)?,
tenant_name: di.tenant_name.clone(),
application_id: Uuid::from_str(&di.application_id)?,
@ -344,7 +362,13 @@ impl IntegrationTrait for Integration {
let e = EventTxAck {
queue_item_id: Uuid::from_str(&pl.queue_item_id)?,
downlink_id: pl.downlink_id as i64,
time: pl.time.as_ref().unwrap().clone().try_into()?,
time: pl
.time
.as_ref()
.unwrap()
.clone()
.try_into()
.map_err(anyhow::Error::msg)?,
tenant_id: Uuid::from_str(&di.tenant_id)?,
tenant_name: di.tenant_name.clone(),
application_id: Uuid::from_str(&di.application_id)?,
@ -380,7 +404,13 @@ impl IntegrationTrait for Integration {
info!(dev_eui = %di.dev_eui, event = "log", "Inserting event");
let e = EventLog {
time: pl.time.as_ref().unwrap().clone().try_into()?,
time: pl
.time
.as_ref()
.unwrap()
.clone()
.try_into()
.map_err(anyhow::Error::msg)?,
tenant_id: Uuid::from_str(&di.tenant_id)?,
tenant_name: di.tenant_name.clone(),
application_id: Uuid::from_str(&di.application_id)?,
@ -418,7 +448,13 @@ impl IntegrationTrait for Integration {
let e = EventStatus {
deduplication_id: Uuid::from_str(&pl.deduplication_id)?,
time: pl.time.as_ref().unwrap().clone().try_into()?,
time: pl
.time
.as_ref()
.unwrap()
.clone()
.try_into()
.map_err(anyhow::Error::msg)?,
tenant_id: Uuid::from_str(&di.tenant_id)?,
tenant_name: di.tenant_name.clone(),
application_id: Uuid::from_str(&di.application_id)?,
@ -456,7 +492,13 @@ impl IntegrationTrait for Integration {
let e = EventLocation {
deduplication_id: Uuid::from_str(&pl.deduplication_id)?,
time: pl.time.as_ref().unwrap().clone().try_into()?,
time: pl
.time
.as_ref()
.unwrap()
.clone()
.try_into()
.map_err(anyhow::Error::msg)?,
tenant_id: Uuid::from_str(&di.tenant_id)?,
tenant_name: di.tenant_name.clone(),
application_id: Uuid::from_str(&di.application_id)?,
@ -495,7 +537,13 @@ impl IntegrationTrait for Integration {
let e = EventIntegration {
deduplication_id: Uuid::from_str(&pl.deduplication_id)?,
time: pl.time.as_ref().unwrap().clone().try_into()?,
time: pl
.time
.as_ref()
.unwrap()
.clone()
.try_into()
.map_err(anyhow::Error::msg)?,
tenant_id: Uuid::from_str(&di.tenant_id)?,
tenant_name: di.tenant_name.clone(),
application_id: Uuid::from_str(&di.application_id)?,

View File

@ -24,7 +24,7 @@ pub async fn save(ds: &internal::PassiveRoamingDeviceSession) -> Result<()> {
};
let lifetime: DateTime<Utc> = match ds.lifetime.clone() {
Some(v) => v.try_into()?,
Some(v) => v.try_into().map_err(anyhow::Error::msg)?,
None => {
debug!("Not saving passive-roaming device-session, no passive-roaming lifetime set");
return Ok(());

View File

@ -1027,7 +1027,8 @@ impl Data {
let record = metrics::Record {
time: DateTime::<Utc>::try_from(
up_event.time.as_ref().unwrap().clone(),
)?
)
.map_err(anyhow::Error::msg)?
.with_timezone(&Local),
kind: match dp_m.kind {
fields::MeasurementKind::COUNTER => metrics::Kind::COUNTER,

View File

@ -69,8 +69,7 @@ pub fn get_rx_timestamp(rx_info: &[gw::UplinkRxInfo]) -> SystemTime {
// Then search for time.
for rxi in rx_info {
if let Some(ts) = &rxi.time {
let ts: core::result::Result<DateTime<Utc>, core::num::TryFromIntError> =
ts.clone().try_into();
let ts: Result<DateTime<Utc>> = ts.clone().try_into().map_err(anyhow::Error::msg);
if let Ok(ts) = ts {
return ts.into();
}
@ -97,8 +96,7 @@ pub fn get_rx_timestamp_chrono(rx_info: &[gw::UplinkRxInfo]) -> DateTime<Utc> {
// Then search for time.
for rxi in rx_info {
if let Some(ts) = &rxi.time {
let ts: core::result::Result<DateTime<Utc>, core::num::TryFromIntError> =
ts.clone().try_into();
let ts: Result<DateTime<Utc>> = ts.clone().try_into().map_err(anyhow::Error::msg);
if let Ok(ts) = ts {
return ts;
}

View File

@ -98,7 +98,9 @@ impl Stats {
let mut m = metrics::Record {
time: match &self.stats.time {
Some(v) => DateTime::try_from(v.clone())?.into(),
Some(v) => DateTime::try_from(v.clone())
.map_err(anyhow::Error::msg)?
.into(),
None => Local::now(),
},
kind: metrics::Kind::ABSOLUTE,