Skip to content
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

Add LivelinessSubscriber history option #648

Merged
merged 6 commits into from
Sep 10, 2024
Merged
Changes from all commits
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
7 changes: 4 additions & 3 deletions src/liveliness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub extern "C" fn zc_liveliness_undeclare_token(
/// @brief The options for `zc_liveliness_declare_subscriber()`
#[repr(C)]
pub struct zc_liveliness_subscriber_options_t {
_dummy: u8,
history: bool,
}

/// @attention Unstable feature.
Expand All @@ -145,7 +145,7 @@ pub struct zc_liveliness_subscriber_options_t {
pub extern "C" fn zc_liveliness_subscriber_options_default(
this: &mut MaybeUninit<zc_liveliness_subscriber_options_t>,
) {
this.write(zc_liveliness_subscriber_options_t { _dummy: 0 });
this.write(zc_liveliness_subscriber_options_t { history: false });
}

/// @attention Unstable feature.
Expand All @@ -164,7 +164,7 @@ pub extern "C" fn zc_liveliness_declare_subscriber(
session: &z_loaned_session_t,
key_expr: &z_loaned_keyexpr_t,
callback: &mut z_moved_closure_sample_t,
_options: Option<&mut zc_liveliness_subscriber_options_t>,
options: Option<&mut zc_liveliness_subscriber_options_t>,
) -> result::z_result_t {
let this = this.as_rust_type_mut_uninit();
let session = session.as_rust_type_ref();
Expand All @@ -173,6 +173,7 @@ pub extern "C" fn zc_liveliness_declare_subscriber(
match session
.liveliness()
.declare_subscriber(key_expr)
.history(options.is_some_and(|o| o.history))
.callback(move |sample| {
let sample = sample.as_loaned_c_type_ref();
z_closure_sample_call(z_closure_sample_loan(&callback), sample)
Expand Down