Skip to content

Commit

Permalink
Add LivelinessSubscriber history option (#648)
Browse files Browse the repository at this point in the history
* Add LivelinessSubscriber history option
  • Loading branch information
OlivierHecart authored Sep 10, 2024
1 parent ad18d18 commit 3633de2
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit 3633de2

Please sign in to comment.