Skip to content

Commit

Permalink
More debug information
Browse files Browse the repository at this point in the history
  • Loading branch information
rorbech committed Jul 19, 2024
1 parent ead1fde commit ae0135f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,10 @@ actual object RealmInterop {
}
}

actual fun realm_flx_sync_config_new(user: RealmUserPointer): RealmSyncConfigurationPointer {
return LongPointerWrapper<RealmSyncConfigT>(realmc.realm_flx_sync_config_new(user.cptr()))
}

actual fun realm_config_set_sync_config(realmConfiguration: RealmConfigurationPointer, syncConfiguration: RealmSyncConfigurationPointer) {
realmc.realm_config_set_sync_config(realmConfiguration.cptr(), syncConfiguration.cptr())
}
Expand Down Expand Up @@ -1980,14 +1984,6 @@ actual object RealmInterop {
realmc.realm_object_delete(obj.cptr())
}

actual fun realm_flx_sync_config_new(user: RealmUserPointer): RealmSyncConfigurationPointer {
return LongPointerWrapper<RealmSyncConfigT>(realmc.realm_flx_sync_config_new(user.cptr())).also { ptr ->
// Stop the session immediately when the Realm is closed, so the lifecycle of the
// Sync Client thread is manageable.
realmc.realm_sync_config_set_session_stop_policy(ptr.cptr(), realm_sync_session_stop_policy_e.RLM_SYNC_SESSION_STOP_POLICY_IMMEDIATELY)
}
}

actual fun realm_sync_subscription_id(subscription: RealmSubscriptionPointer): ObjectId {
val nativeBytes: ShortArray = realmc.realm_sync_subscription_id(subscription.cptr()).bytes
val byteArray = ByteArray(nativeBytes.size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3318,11 +3318,7 @@ actual object RealmInterop {
}

actual fun realm_flx_sync_config_new(user: RealmUserPointer): RealmSyncConfigurationPointer {
return CPointerWrapper<RealmSyncConfigT>(realm_wrapper.realm_flx_sync_config_new((user.cptr()))).also { ptr ->
// Stop the session immediately when the Realm is closed, so the lifecycle of the
// Sync Client thread is manageable.
realm_wrapper.realm_sync_config_set_session_stop_policy(ptr.cptr(), realm_sync_session_stop_policy_e.RLM_SYNC_SESSION_STOP_POLICY_IMMEDIATELY)
}
return CPointerWrapper<RealmSyncConfigT>(realm_wrapper.realm_flx_sync_config_new((user.cptr())))
}

actual fun realm_app_sync_client_reconnect(app: RealmAppPointer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ internal open class SyncSessionImpl(
},
progressMode == ProgressMode.INDEFINITELY
) { progressEstimate: Double ->
realm.log.debug("PROGRESS CALLBACK: $progressEstimate")
val progress = Progress(progressEstimate)
trySendWithBufferOverflowCheck(progress)
if (progressMode == ProgressMode.CURRENT_CHANGES && progress.isTransferComplete) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import io.realm.kotlin.Realm
import io.realm.kotlin.entities.sync.SyncObjectWithAllTypes
import io.realm.kotlin.ext.query
import io.realm.kotlin.internal.platform.runBlocking
import io.realm.kotlin.log.LogLevel
import io.realm.kotlin.log.RealmLog
import io.realm.kotlin.mongodb.User
import io.realm.kotlin.mongodb.sync.Direction
import io.realm.kotlin.mongodb.sync.Progress
Expand All @@ -40,6 +42,7 @@ import kotlinx.coroutines.flow.buffer
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.last
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.scan
import kotlinx.coroutines.flow.takeWhile
import kotlinx.coroutines.supervisorScope
Expand Down Expand Up @@ -146,10 +149,12 @@ class FLXProgressListenerTests {

@Test
fun uploadProgressListener_changesOnly() = runBlocking {
RealmLog.setLevel(LogLevel.ALL)
Realm.open(createSyncConfig(app.createUserAndLogin())).use { realm ->
for (i in 0..3) {
realm.writeSampleData(TEST_SIZE, timeout = TIMEOUT)
realm.syncSession.progressAsFlow(Direction.UPLOAD, ProgressMode.CURRENT_CHANGES)
.onEach { println("PROGRESS LISTENER: $it") }
.run {
withTimeout(TIMEOUT) {
last().let {
Expand Down

0 comments on commit ae0135f

Please sign in to comment.