-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce6c44f
commit 3dc22f0
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use super::Time; | ||
|
||
/// A point in time (PIT) is a point that represents a consistent view of the data at that time. | ||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)] | ||
pub struct PointInTime { | ||
id: String, | ||
keep_alive: Time, | ||
} | ||
|
||
impl PointInTime { | ||
/// Creates a new instance of [`PointInTime`]. | ||
/// | ||
/// - The `id` parameter tells Elasticsearch to execute the request using contexts from this point in time. | ||
/// - The `keep_alive` parameter tells Elasticsearch how long it should extend the time to live of the point in time. | ||
pub fn new<T>(id: T, keep_alive: Time) -> Self | ||
where | ||
T: ToString, | ||
{ | ||
Self { | ||
id: id.to_string(), | ||
keep_alive, | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use crate::{util::assert_serialize, Search}; | ||
|
||
#[test] | ||
fn adds_boolean() { | ||
assert_serialize( | ||
Search::new().pit(PointInTime::new("46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA", Time::Minutes(1))), | ||
json!({ | ||
"pit": { | ||
"id": "46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA", | ||
"keep_alive": "1m" | ||
} | ||
}), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters