@@ -4,7 +4,6 @@ import io.ably.lib.objects.ObjectMessage
44import io.ably.lib.objects.ObjectOperation
55import io.ably.lib.objects.ObjectState
66import io.ably.lib.objects.ObjectsOperationSource
7- import io.ably.lib.objects.ObjectsPoolDefaults
87import io.ably.lib.objects.objectError
98import io.ably.lib.objects.type.livecounter.noOpCounterUpdate
109import io.ably.lib.objects.type.livemap.noOpMapUpdate
@@ -138,10 +137,20 @@ internal abstract class BaseRealtimeObject(
138137
139138 /* *
140139 * Checks if the object is eligible for garbage collection.
140+ *
141+ * An object is eligible for garbage collection if it has been tombstoned and
142+ * the time since tombstoning exceeds the specified grace period.
143+ *
144+ * @param gcGracePeriod The grace period in milliseconds that tombstoned objects
145+ * should be kept before being eligible for collection.
146+ * This value is retrieved from the server's connection details
147+ * or defaults to 24 hours if not provided by the server.
148+ * @return true if the object is tombstoned and the grace period has elapsed,
149+ * false otherwise
141150 */
142- internal fun isEligibleForGc (): Boolean {
151+ internal fun isEligibleForGc (gcGracePeriod : Long ): Boolean {
143152 val currentTime = System .currentTimeMillis()
144- return isTombstoned && tombstonedAt?.let { currentTime - it >= ObjectsPoolDefaults . GC_GRACE_PERIOD_MS } == true
153+ return isTombstoned && tombstonedAt?.let { currentTime - it >= gcGracePeriod } == true
145154 }
146155
147156 /* *
@@ -198,12 +207,22 @@ internal abstract class BaseRealtimeObject(
198207 /* *
199208 * Called during garbage collection intervals to clean up expired entries.
200209 *
210+ * This method is invoked periodically (every 5 minutes) by the ObjectsPool
211+ * to perform cleanup of tombstoned data that has exceeded the grace period.
212+ *
201213 * This method should identify and remove entries that:
202214 * - Have been marked as tombstoned
203- * - Have a tombstone timestamp older than the configured grace period
215+ * - Have a tombstone timestamp older than the specified grace period
216+ *
217+ * @param gcGracePeriod The grace period in milliseconds that tombstoned entries
218+ * should be kept before being eligible for removal.
219+ * This value is retrieved from the server's connection details
220+ * or defaults to 24 hours if not provided by the server.
221+ * Must be greater than 2 minutes to ensure proper operation
222+ * ordering and avoid issues with delayed operations.
204223 *
205224 * Implementations typically use single-pass removal techniques to
206225 * efficiently clean up expired data without creating temporary collections.
207226 */
208- abstract fun onGCInterval ()
227+ abstract fun onGCInterval (gcGracePeriod : Long )
209228}
0 commit comments