Skip to content

Commit

Permalink
Allow subscribing only with the supported flags.
Browse files Browse the repository at this point in the history
  • Loading branch information
iddm committed Dec 5, 2023
1 parent ab5902f commit 023af7f
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,19 @@ macro_rules! redis_event_handler {
$crate::raw::Status::Ok as c_int
}

let all_available_flags = $crate::raw::get_keyspace_notification_flags_all();
if !all_available_flags.contains($event_type) {
let not_supported = $event_type.difference(all_available_flags);
log::warn!("The event notification flags set aren't supported: {not_supported:?}");

// $crate::Context::new($ctx).log_warning(&format!(
// "The event notification flags set aren't supported: {not_supported:?}"
// ));
let all_available_notification_flags = $crate::raw::get_keyspace_notification_flags_all();
let available_wanted_notification_flags = $event_type.intersection(all_available_notification_flags);
if !all_available_notification_flags.contains($event_type) {
let not_supported = $event_type.difference(all_available_notification_flags);
$crate::Context::new($ctx).log_notice(&format!(
"These event notification flags set aren't supported: {not_supported:?}. These flags will be used: {available_wanted_notification_flags:?}"
));
}

if unsafe {
if !available_wanted_notification_flags.is_empty() && unsafe {
$crate::raw::RedisModule_SubscribeToKeyspaceEvents.unwrap()(
$ctx,
$event_type.bits(),
available_wanted_notification_flags.bits(),
Some(__handle_event),
)
} == $crate::raw::Status::Err as c_int
Expand Down

0 comments on commit 023af7f

Please sign in to comment.