← All changes
|
jetpack_vendor/automattic/jetpack-sync/src/class-health.php
+18
-0
13.5.2
→
16.3
View file →
| @@ -174,8 +174,26 @@ | ||
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | + * Check if the sync queue is healthy based on size and lag. | |
| 179 | + * | |
| 180 | + * The queue is considered healthy if either size OR lag is within its limit. | |
| 181 | + * This matches the logic in Listener::can_add_to_queue(): data loss only occurs | |
| 182 | + * when both limits are exceeded simultaneously. | |
| 183 | + * | |
| 184 | + * @param int $queue_size Current queue size. | |
| 185 | + * @param float $queue_lag Current queue lag in seconds. | |
| 186 | + * @param int $max_queue_size Maximum allowed queue size. | |
| 187 | + * @param float $max_queue_lag Maximum allowed queue lag in seconds. | |
| 188 | + * @return bool Whether the queue is healthy. | |
| 189 | + */ | |
| 190 | + public static function is_queue_healthy( $queue_size, $queue_lag, $max_queue_size, $max_queue_lag ) { | |
| 191 | + return ( $queue_size < $max_queue_size ) | |
| 192 | + || ( $queue_lag < $max_queue_lag ); | |
| 193 | + } | |
| 194 | + | |
| 195 | + /** | |
| 178 | 196 | * Update Sync Status if Full Sync ended of Posts |
| 179 | 197 | * |
| 180 | 198 | * @param string $checksum The checksum that's currently being processed. |
| 181 | 199 | * @param array $range The ranges of object types being processed. |