-
Notifications
You must be signed in to change notification settings - Fork 12
Implement timestamp generators and enable 4 out of 5 TimestampTests #295
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ee4a9b9
timestamp: implement cass_timestamp_gen_ methods
muzarski 9d3e178
cluster: implement cass_cluster_set_timestamp_gen
muzarski 75eb8f9
testing: remove cass_cluster_set_timestamp_gen from unimplemented
muzarski 3acb09e
readme: remove timestamp entries
muzarski 1edef79
cpp: remove timestamp methods from src/
muzarski 0b8a952
it: enable 4 out of 5 TimestampTests
muzarski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,60 @@ | ||
use std::sync::Arc; | ||
use std::time::Duration; | ||
|
||
use scylla::policies::timestamp_generator::MonotonicTimestampGenerator; | ||
|
||
use crate::argconv::{BoxFFI, CMut, CassOwnedExclusivePtr, FFI, FromBox}; | ||
|
||
pub enum CassTimestampGen { | ||
ServerSide, | ||
Monotonic(Arc<MonotonicTimestampGenerator>), | ||
} | ||
|
||
impl FFI for CassTimestampGen { | ||
type Origin = FromBox; | ||
} | ||
|
||
#[unsafe(no_mangle)] | ||
pub unsafe extern "C" fn cass_timestamp_gen_server_side_new() | ||
-> CassOwnedExclusivePtr<CassTimestampGen, CMut> { | ||
BoxFFI::into_ptr(Box::new(CassTimestampGen::ServerSide)) | ||
} | ||
|
||
#[unsafe(no_mangle)] | ||
pub unsafe extern "C" fn cass_timestamp_gen_monotonic_new() | ||
-> CassOwnedExclusivePtr<CassTimestampGen, CMut> { | ||
BoxFFI::into_ptr(Box::new(CassTimestampGen::Monotonic(Arc::new( | ||
// Generator with default settings (warning_threshold=1s, warning_interval=1s) | ||
MonotonicTimestampGenerator::new(), | ||
)))) | ||
} | ||
|
||
#[unsafe(no_mangle)] | ||
pub unsafe extern "C" fn cass_timestamp_gen_monotonic_new_with_settings( | ||
warning_threshold_us: i64, | ||
warning_interval_ms: i64, | ||
) -> CassOwnedExclusivePtr<CassTimestampGen, CMut> { | ||
let generator = if warning_threshold_us <= 0 { | ||
// If threshold is <= 0, we disable the warnings. | ||
MonotonicTimestampGenerator::new().without_warnings() | ||
} else { | ||
let warning_threshold = Duration::from_micros(warning_threshold_us as u64); | ||
let warning_interval = if warning_interval_ms <= 0 { | ||
// Inverval <= 0 fallbacks to 1ms. | ||
Duration::from_millis(1) | ||
} else { | ||
Duration::from_millis(warning_interval_ms as u64) | ||
}; | ||
|
||
MonotonicTimestampGenerator::new().with_warning_times(warning_threshold, warning_interval) | ||
}; | ||
|
||
BoxFFI::into_ptr(Box::new(CassTimestampGen::Monotonic(Arc::new(generator)))) | ||
} | ||
|
||
#[unsafe(no_mangle)] | ||
pub unsafe extern "C" fn cass_timestamp_gen_free( | ||
timestamp_gen_raw: CassOwnedExclusivePtr<CassTimestampGen, CMut>, | ||
) { | ||
BoxFFI::free(timestamp_gen_raw) | ||
} |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.