File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -804,6 +804,28 @@ impl Context {
804804 . into( )
805805 }
806806 ) ;
807+
808+ api ! (
809+ [ RedisModule_AvoidReplicaTraffic ] ,
810+ /// Returns true if a client sent the CLIENT PAUSE command to the server or
811+ /// if Redis Cluster does a manual failover, pausing the clients.
812+ /// This is needed when we have a master with replicas, and want to write,
813+ /// without adding further data to the replication channel, that the replicas
814+ /// replication offset, match the one of the master. When this happens, it is
815+ /// safe to failover the master without data loss.
816+ ///
817+ /// However modules may generate traffic by calling commands or directly send
818+ /// data to the replication stream.
819+ ///
820+ /// So modules may want to try to avoid very heavy background work that has
821+ /// the effect of creating data to the replication channel, when this function
822+ /// returns true. This is mostly useful for modules that have background
823+ /// garbage collection tasks, or that do writes and replicate such writes
824+ /// periodically in timer callbacks or other periodic callbacks.
825+ pub fn avoid_replication_traffic( & self ) -> bool {
826+ unsafe { RedisModule_AvoidReplicaTraffic ( ) == 1 }
827+ }
828+ ) ;
807829}
808830
809831extern "C" fn post_notification_job_free_callback < F : FnOnce ( & Context ) > ( pd : * mut c_void ) {
You can’t perform that action at this time.
0 commit comments