Skip to content

RUST-666 Add options for timeseries collection creation #381

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
Jun 30, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
serde(default) for expire_after_seconds
  • Loading branch information
abr-egn committed Jun 29, 2021
commit 0a38dfa1838c5e8f963d0fa6fe683611afa685d9
6 changes: 4 additions & 2 deletions src/db/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ pub struct CreateCollectionOptions {
/// Specifies options for creating a timeseries collection.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we document here that this feature is only available on 5.0+?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, done.

pub timeseries: Option<TimeseriesOptions>,

/// Number indicating after how many seconds old time-series data should be deleted.
#[serde(deserialize_with = "bson_util::deserialize_duration_from_u64_seconds",
/// Duration indicating after how long old time-series data should be deleted.
#[serde(
default,
Copy link
Contributor Author

@abr-egn abr-egn Jun 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why this field needs to be explicitly marked as using the default when it's not present when others don't, but without this annotation some tests fail in deserialization complaining about missing field "expireAfterSeconds".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's because we provide special serialization / deserialization helpers for this field which override the default behavior.

deserialize_with = "bson_util::deserialize_duration_from_u64_seconds",
serialize_with = "bson_util::serialize_duration_option_as_int_secs")]
pub expire_after_seconds: Option<Duration>,
}
Expand Down