Skip to content

Commit

Permalink
Modify policy interval
Browse files Browse the repository at this point in the history
- Change the `Interval`/`RequestedInterval` enum to include the new fields.
- Fix clippy error.
- Bump the new rio version 0.3.1+rio.0.0.1.
  • Loading branch information
kimhanbeom committed Jan 24, 2024
1 parent 00b7d7d commit ab9c463
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ file is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and
this project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- Change the `Interval`/`RequestedInterval` enum to include the new fields.
(FifteenSeconds,ThirtySeconds,OneMinutes)

## [0.3.1] - 2023-11-07

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "crusher"
version = "0.3.1"
version = "0.3.1+rio.0.0.1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn config(certs: Vec<Certificate>, key: PrivateKey, files: Vec<Vec<u8>>) ->
.into_iter()
.map(rustls::Certificate)
.collect();
if let Some(cert) = root_cert.get(0) {
if let Some(cert) = root_cert.first() {
root_store.add(cert)?;
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ use std::net::IpAddr;
#[derive(Clone, Copy, IntoPrimitive, Deserialize, Debug)]
#[repr(u32)]
pub enum Interval {
FifteenSeconds = 15,
ThirtySeconds = 30,
OneMinutes = 60,
FiveMinutes = 300,
TenMinutes = 600,
FifteenMinutes = 900,
Expand All @@ -24,6 +27,9 @@ pub enum Interval {
impl From<RequestedInterval> for Interval {
fn from(i: RequestedInterval) -> Self {
match i {
RequestedInterval::FifteenSeconds => Self::FifteenSeconds,
RequestedInterval::ThirtySeconds => Self::ThirtySeconds,
RequestedInterval::OneMinutes => Self::OneMinutes,
RequestedInterval::FiveMinutes => Self::FiveMinutes,
RequestedInterval::TenMinutes => Self::TenMinutes,
RequestedInterval::FifteenMinutes => Self::FifteenMinutes,
Expand Down
13 changes: 8 additions & 5 deletions src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ pub enum RequestedKind {
#[derive(Debug, Deserialize, TryFromPrimitive, Clone)]
#[repr(u32)]
pub enum RequestedInterval {
FiveMinutes = 0,
TenMinutes = 1,
FifteenMinutes = 2,
ThirtyMinutes = 3,
OneHour = 4,
FifteenSeconds = 0,
ThirtySeconds = 1,
OneMinutes = 2,
FiveMinutes = 3,
TenMinutes = 4,
FifteenMinutes = 5,
ThirtyMinutes = 6,
OneHour = 7,
}

#[derive(Debug, Deserialize, TryFromPrimitive, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion src/subscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ async fn publish_connect(
async fn calculate_series_start_time(req_pol: &RequestedPolicy) -> Result<i64> {
let mut start: i64 = 0;
if let Some(last_time) = LAST_TRANSFER_TIME.read().await.get(&req_pol.id.to_string()) {
let Some(period) = u32::from(Period::try_from(req_pol.period.clone())?).to_i64() else {
let Some(period) = u32::from(Period::from(req_pol.period.clone())).to_i64() else {
bail!("Failed to convert period");
};
let Some(period_nano) = period.checked_mul(SECOND_TO_NANO) else {
Expand Down

0 comments on commit ab9c463

Please sign in to comment.