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 @@ -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
814836extern "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