Skip to content

Commit 334f06b

Browse files
authored
Merge branch 'master' into improve-the-info-handler
2 parents 4a67005 + 4e9ccd7 commit 334f06b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/context/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,28 @@ impl Context {
809809
.into()
810810
}
811811
);
812+
813+
api!(
814+
[RedisModule_AvoidReplicaTraffic],
815+
/// Returns true if a client sent the CLIENT PAUSE command to the server or
816+
/// if Redis Cluster does a manual failover, pausing the clients.
817+
/// This is needed when we have a master with replicas, and want to write,
818+
/// without adding further data to the replication channel, that the replicas
819+
/// replication offset, match the one of the master. When this happens, it is
820+
/// safe to failover the master without data loss.
821+
///
822+
/// However modules may generate traffic by calling commands or directly send
823+
/// data to the replication stream.
824+
///
825+
/// So modules may want to try to avoid very heavy background work that has
826+
/// the effect of creating data to the replication channel, when this function
827+
/// returns true. This is mostly useful for modules that have background
828+
/// garbage collection tasks, or that do writes and replicate such writes
829+
/// periodically in timer callbacks or other periodic callbacks.
830+
pub fn avoid_replication_traffic(&self) -> bool {
831+
unsafe { RedisModule_AvoidReplicaTraffic() == 1 }
832+
}
833+
);
812834
}
813835

814836
extern "C" fn post_notification_job_free_callback<F: FnOnce(&Context)>(pd: *mut c_void) {

0 commit comments

Comments
 (0)