Skip to content

Commit

Permalink
Introduce is_no_sync method on Query
Browse files Browse the repository at this point in the history
  • Loading branch information
adzialocha committed Nov 17, 2024
1 parent c2c1fb0 commit e012aed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 2 additions & 6 deletions rhio/src/network/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ impl<'a> SyncProtocol<'a, Query> for RhioSyncProtocol {
//
// The current p2panda API does not give any control to turn off syncing for some data
// stream subscriptions, this is why we're doing it this hacky way.
if matches!(query, Query::NoSyncSubject { .. })
|| matches!(query, Query::NoSyncBucket { .. })
{
if query.is_no_sync() {
debug!(parent: &span, "end sync session prematurely as we don't want to have one");
return Ok(());
}
Expand Down Expand Up @@ -257,9 +255,7 @@ impl<'a> SyncProtocol<'a, Query> for RhioSyncProtocol {
//
// @TODO(adz): This is a workaround to disable syncing in some cases as the current p2panda
// API does not give any control to turn off syncing for some topics.
if matches!(query, Query::NoSyncSubject { .. })
|| matches!(query, Query::NoSyncBucket { .. })
{
if query.is_no_sync() {
debug!(parent: &span, "end sync session prematurely as we don't want to have one");
return Ok(());
}
Expand Down
7 changes: 7 additions & 0 deletions rhio/src/topic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ impl Query {
}
}

pub fn is_no_sync(&self) -> bool {
match self {
Self::NoSyncBucket { .. } | Self::NoSyncSubject { .. } => true,
_ => false,
}
}

fn prefix(&self) -> &str {
match self {
Self::Bucket { .. } => "bucket",
Expand Down

0 comments on commit e012aed

Please sign in to comment.